Ok, so you drew the dialog in part 1 but it's fsckin useless, it doesn't
even show up when you run it. Not to worry, when you finish this section,
the dialog will show up when you run it. It will also close itself when you
click on the Quit button. Woohoo!
(ok, it's not that exciting...but it's better then nothing)
Making Stuff Appear
First we want to make a connection from the bean's initializ()
method to the show() method of the JFrame. Read over the next
few steps and look at the pictures, then go forth and connectify...or
something
Right click outside of your JFrame and click Connect... from the
menu that pops up
|
|
Well, you don't have a lot of choice here. The initialize() event
is fired when an instance your Bean is created. We can add listeners to
this event, so when it happens, actions we specify are taken. For now,
just click Ok
|
|
Now you should have a line on the screen following the cursor around (which
has changed to a strange-looking little spider shape. Who comes up with these
things?). You want to click on the titlebar of the JFrame
|
|
Ok, now you'll get a menu of common methods that we can connect to in a
JFrame. We want the show() method.
|
|
What have we done!?!??!
Well, we connected the initialize() event of the bean to the
show() method of the JFrame. This means that whenever the
initialize() event is fired, the show() method of the JFrame gets
called. Pretty straightforward...
Making Stuff Go Away
We want the Quit button to make the JFrame go away. When you want
a button click to have an effect, you make a connection from the
ActionPerformed event...
|
|
The method that makes a JFrame go away is the dispose() method, so
hook the ActionPerformed event up to that.
|
|
Are We There Yet?
Yes. Well probably. Your screen should look something like the following
picture. If you don't have green lines from the Quit button and the White
Void to the JFrame, take another crack at it. If all is well, try clicking
the Run button in VAJ. Your JFrame should appear, almost as if by
magic. Then click Quit and if you did it right the JFrame will
disappear. w3rd! On to the next section...
Part 3: Being Objective
Back to the Tutorial
|