Java - Bailey & Bailey Elements Help

S

smokymcpot_00

Hi

I'm doing a computer games development degree which includes a java
programming class. In this they use an Elements package (by 'Bailey &
Bailey') which is used for drawing objects in a bitmap drawing window.
When creating a new drawing window I use the following code:

DrawingWindow d = new DrawingWindow();

This creates a new drawing window with the name "d" which I would use
to draw an object (e.g d.draw(Rect);)

However this seems to be only local to the method I include it in,
which is'nt very helpful. I was wondering if anyone has had any
experience with the Elements package and if they could help me make "d"
public to all other methods in the class.

Thanks in advance,
dev_wannabe
 
S

smokymcpot_00

Just found the answer to my own question lol so thought I'd post it
here in case there happens to be someone else out there in pooter-land
with the same problem as me :eek:)

example code
==========

import element.*;

public class simpleDrawingExample
{
static DrawingWindow d;

public static void draw_head(int x, int y, int width, int height)
{
Oval oval_head = new Oval(x,y,width,height);

d.draw(oval_head);
}

public static void main(String[] args)
{
d = new DrawingWindow();
draw_head(100,100,20,30);
}
}

============

all that had to be done was put "static DrawingWindow d" outside of a
method and use "d = new DrawingWindow();" when I wanted to open up the
drawing window for the first time

Ahhhh us n00bs with out silly little puzzles :p

Thanks,
dev_wannabe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top