Tuesday, March 31, 2009

Tuesday March 31: taste the HTML rainbow, part four

OK, but what if you want to be abkle to follow links inside a webpage? Like say for example, go to the "Images" section of Google? Well to do that, you have to use a new kind of listener, a
"HyperlinkListener"

Here's what you do:


add this -- > , HyperlinkListener
after this: implements ActionListener

add this:
Webapalooza.addHyperlinkListener(this);
underneath
Webapalooza.setEditable(false);

add this code block underneath the actionPerformed method:

public void hyperlinkUpdate(HyperlinkEvent evt)
{
if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
try
{
Webapalooza.setPage(evt.getURL());
} //end try
catch(IOException ioe)
{ } //end catch
}//end if


} //end hyperlinkEvent

Tuesday March 31: taste the HTML rainbow, part three

OK, so now we've got a program that can display a webpage in a JEditorPane, but its kind of like ropeless bungee jumping: it might be exciting, but only for a very brief time, then the thrill is gone. Soooooooooooooooooooooooooooooooooooooooooooo, let's make it so that you can change the webpage loaded into the JEditorPane by entering an address. Here's how I did it:



Declare these two components

JTextField WebAddy;
JButton ChangeAddy;



then add these two components to your constructor:

//create JTextField, set text to first webpage String
WebAddy = new JTextField(StartPage);
WebAddy.setBounds(345,0,200,20); //size and place it
WebAddy.addActionListener(this);
ProvingGround.add(WebAddy); //add to container


ChangeAddy = new JButton("Go There"); //create JButton
ChangeAddy.setBounds(180,0,165,35); //size and place it
ChangeAddy.addActionListener(this);
ProvingGround.add(ChangeAddy); //add to container


add an "else if" statement for the ChangeAddy JButton


else if (e.getSource() == ChangeAddy)
{
//StartPage = WebAddy.getText( );
try {
Webapalooza.setPage(new URL(WebAddy.getText()));
// urlField.setText(url);
} //end try

catch(IOException ioe)
{
System.out.println("crap!");
}//end catch
}//end else for ChangeAddy JButton



Save, compile and run; you should be able to load another website into your JEditorPane by typing the address in the JTextField then hitting the new JButton



Cheers,

Uncle Paulie

Tuesday March 31: taste the HTML rainbow, part two

OK, now setting colors is all very cool, but it starts me to wondering: isn't the World Wide Web just full of color? It sure looks that way to me. Plus -- and maybe this hasn't been on YOUR mind lately, but I've been thinking about it-- there should be some way in Java to make a webpage viewer, same as in Visual Basic, right? Well of course there is. It's called a JEditorPane. Let's get introduced, shall we?

The first thing you have to do is to add these imports
import java.io.*; //for try catch to make JEditorPane
import java.net.*; //for use with setting new URL for JEditorPane

Creating a JEditorPane is not as simple as it might seem: because you're trying to load a webpage, and the webpage might not be there, you have to do it in a "try catch", which is sort of like an if else statement.

Next step, add these declarations:
JEditorPane Webapalooza;
String StartPage = "http://www.google.com";


And add this to your constructor, just below where you added the "Skittles" button:

//setup JEditorPane using try catch
try {
Webapalooza = new JEditorPane(StartPage);
Webapalooza.setEditable(false); //this component can be used to edit, but not now
Webapalooza.setBounds(0,50,780,550);
ProvingGround.add(Webapalooza);
} //end try
catch(IOException ioe)
{ } //end empty catch

Now when you run your program, you should see the webpage for Google displayed in the JEditorPane

Tuesday March 31: taste the HTML rainbow, part one

Greetings and salutations, fellow code jockeys!



Today, we shall continue onwards with an exploration of Java Swing; and the first step on this journey is to download the file located here:



http://www.box.net/shared/j6j4def1kc



The file inside is functional and will start up a JFrame with a pretty red background. It has an empty actionPerformed method, and its setup so that when you close the JFrame, you shut down the whole program. Beyond that, it doesn't do much; there's not even a component that could make anything happen. So let's change that right now, m'OK?



A) just below this line in the declarations section:

Container ProvingGround;

add this line to declare a JButton:

JButton Skittles;



B) In the constructor, just below this line:

ProvingGround.setLayout(null);

add this code block to create and enable the JButton you just declared:

Skittles = new JButton("Taste The Rainbow");
Skittles.setBounds(0,0,165,35); // null layout makes you use this
Skittles.setBackground(Color.blue);
Skittles.addActionListener(this);
ProvingGround.add(Skittles);




C) Finally, and most importantly, you have to add an if statement to your actionPerformed method, so that when you click the "Skittles" button, it pops up what's known as a JColorChooser Dialog. This dialog box allows you to choose a color, either by clicking on a box, or by setting integer values; you can then apply this color to the Container background:

if (e.getSource() == Skittles)

{

//pop up JColorChooser dialog box

Color TieDye = JColorChooser.showDialog(this,"Hey Man, the Colorz!", getBackground());

if (TieDye != null) //chose a color?

//change the Container Color to what you chose

ProvingGround.setBackground(TieDye);

}// end choose color Skittles button



PLEASE NOTE: the line that starts with "Color TieDye" got wrapped to the next line; please put both lines you see here on one line.



OK, that oughta do it; compile it and run, then see if it works for you.



Btw, if you somehow can apply the colors you find in this dialog at runtime, that would be cool. Not necessary, but cool.



Cheers,

Uncle Paulie

Sunday, March 29, 2009

Monday March 30: add a JMenu !

So OK, I said at the beginning that Swing components were a lot like the older style, except they had a J at the front of them. So here is what you need to do: you've made Menus before, so let's use copy and paste, and a little knowledge of how to type the letter "J" to include a JMenu with at least one JMenuItem on this program. They don't have to do anything, let's see you get 'em on here!

And a special challenge: see if you can get an image onto one of your JMenuItems. The code is pretty darned similar to the stuff we've just done

Cheers,
Uncle Paulie

Monday March 30: a null layout for the whole program? Sort of....

OK, our next trick will involve a little bit of skullduggery from the old AWT library: just because we're suing Swing doesn't mean we have to forswear the old ways entirely. Here is a way to ensure that your program starts up at center screen, no matter what it's size:

//make a Toolkit object
Toolkit TK = getToolkit();
//use toolkit object to find screen size
Dimension size = TK.getScreenSize();

//subtract 1/2 the width of JFrame from 1/2 the width of screen
//do the same for height
setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);

The Toolkit is actually part of the AWT libraries, but as you can see from this example, it can be used even with swing based programs. It has its best use when creating a Splash screen: a window controlled by a Timer bearing some sort of information about the program. It lasts for about 5 to 10 seconds, then vanishes to be replaced by a Frame , or JFrame in this case


OK, onwards to see if yuo can handle a VERY small leap!

Uncle Paulie

Monday March 30: SWING into spring with a new layout and a new startup position

Greetings JavaNoidz!

Well, its almost one of my favorite days, April 1, and to celebrate, I want to start this week off by looking at an updated version of Java called "swing". There's three things you should know right off the bat:

A) Everything in Swing is typed the same as in AWT, but with a "J" in front of it: JFrame, JButton, JTextField, etc etc

B) Swing components like JButtons are not loaded directly onto JFrames, but into "Containers"

C) There's some cool new things you can do in Swing that you can't do in AWT

OK, so let's get going. There's a folder online at Box.net that has two files in it: one a Java file which you will build on, the other being a small image file. Please download both from here:
http://www.box.net/shared/010jen6jjn

and put them into a folder named after yourself plus the word "swing"

When you load this program into TextPad, you will notice that there is a line of code that ends with "(EXIT_ON_CLOSE)" What this does is to close the JFrame AND shut down the program.

You will also notice that the JFrame has a Container object which will be used to hold components AND its layout has been set to "null". This allows you to position components exactly where you want them; BUT, you have to use the "setBounds" method for pretty much all of them. So OK, let's add a swing component and see it happen:

right below this line of code:
ProvingGround.setLayout(null);

add these lines:
JButton NewButton = new JButton("Look A JButton!");
NewButton.setBounds(0,0,165,65);
ProvingGround.add(NewButton);

compile it and run it, and you will see a button. No big deal; except, let's add another one and see if we can get something a little different:
ImageIcon buzzed = new ImageIcon("Feine.gif");
JButton PicButton = new JButton(buzzed);
PicButton.setBounds(100,200,195,65);
ProvingGround.add(PicButton);

ImageIcons can be used to add images to components, including, well JButtons. Notice that this image was found in the same folder as your program; if it was elsewhere, you'd need to somehow inform your program of this.

Let's try one more:
JButton ImageNtexT = new JButton("Wired", buzzed);
ImageNtexT.setBounds(300,100,165,65);
ProvingGround.add(ImageNtexT);

OK, for our next trick, let's look at doing some absolute positioning for the JFrame itself. Onward to the next posting!

Ubcle Paulie

Thursday, March 26, 2009

Thursday March 26: Projects must be finished up and handed in today!

Greetings, fellow code warriors!

Today, we have a lunch block. It's also the last time I will meet with you this week, and its effectively the last time we will meet for this marking period. With that in mind, it's time for you to finish the projects we started back in the middle of the month. The requirements for your projects were listed HERE

Please finish up to the best of your ability. You have a great deal of time, and you may use all the resources available, including all previous posts, all group discussions, all previous programs, each other, and me. You may also of course apply techniques you have learned outside the coursework I have assigned, including that taught to you yesterday by one of your peers.

Make sure to send me by attachment ALL files relevant to your project, and remember to put your name and the phrase "last version" in the subject line.

Also, you will need to create a final post to do with this project; in it, I will need you to record all thoughts, observations and suggestions for future projects.

Cheers,
Uncle Paulie

Wednesday, March 25, 2009

How Ryan N. gets it done: instructions for making the FileSave work!

Today I, Lord Berserkguard, protector of the Alliance, am going to show you how to write files in Java – a little more advanced that the basic I/O you know with the console printing.

The class we are going to work with is called FileWriter – you can pretty much tell what it does

We are also going to use a Javax control called JFileChooser as a way for the user to navigate to the file/folder to save. Remember – we have to import javax.swing.* for this to work properly. The program I uploaded already has that import statement, so you don’t need to worry about it for this example.

http://www.box.net/shared/jb0u5k2lhh
Open up that file posted above, and you should see some import statements, a pre-made Frame for you, and an ActionPerformed event. Make a menu bar like you have in the past, with one MenuItem for a save function. Don’t forget to add an action listener to the MenuItem, otherwise it will just look pretty and not actually do anything.

Once you have done that, declare and add a TextArea to the Frame

(HINT: This is declared and used just about exactly the same as a TextField – if you still have trouble I will show you how to do it, there is also a line of commenting ALREADY IN THE PROGRAM which tells you the parameters it takes)

Add this under the if (e.getSource() == saveFile){ in the ActionPerformed:
If the name of your MenuItem isn’t saveFile, than you have to change the name of that to whatever you named your MenuItem.

Declare a string which is set to the User’s current directory:

String wd = System.getProperty("user.dir");

Now, for the JFileChooser implementation – the parameter is the directory to start in, which was set using System.getProperty("user.dir");.

JFileChooser fc = new JFileChooser(wd);

Lastly, to show the dialog, you call the showDialog() command from the JFileChooser
(In this case, it’s named fc)
The command takes 2 parameters (parent and approveButtonText):
The parent parameter isn’t all that important, and for all intensive purposes can just be set to NULL. The second parameter is the text you want the button on the dialog to display.
int rc = fc.showDialog(null, "Save File");

Notice how you see the showDialog returns an integer – this is because the showDialog will return either a 0 or a 1 based on input. We can than use rc to check if the user clicked the “Save File” button or cancelled out of the dialog.

So now we check if the user approved (clicked “Save File”)
Do this by adding this ‘if’ statement:
if (rc == JFileChooser.APPROVE_OPTION){

}
If you wanna get creative, the APPROVE_OPTION could also be something like CANCEL_OPTION or ERROR_OPTION, depends on what you want to check for. For now let’s stick with the APPROVE_OPTION.

In between this ‘if’ statement, declare a File and set it to the file that the user selected from the JFileChooser. getSelectedFile(); returns the file that was selected as type File – which is why we declare it the way we do.

File file = fc.getSelectedFile();

Once you add that, declare a String and set it to the file’s location
(getAbsolutePath() returns the whole file path, for example, “C://Documents and Settings/this.txt”. getName() only returns the file name, as in “that.txt”)

String filename = file.getAbsolutePath();

Now that the String is set to the full path that the user navigated to, we can use it to specify where the file should be written. We have to use a ‘try’ block – all that does is try to do something, and if there is an error, it raises an exception using ‘catch’. Pretty simple, although it throws many people off unless they know what it does. Declare that now by adding these lines:

try{

}

After you’ve done that, we can now attempt to write a file. To do this, we declare a FileWriter, and set the parameter to the path that the user chose with the JFileChooser (in this case, the String named ‘filename’)

FileWriter writer = new FileWriter( filename );

Now that you have initiated a FileWriter, you should close it when you are done with it; otherwise it takes up system resources, which in some cases make the program unresponsive. To close a FileWriter, use the close() command. Since I named my FileWriter writer, I would close it by typing writer.close();

Now you should have a try block with a FileWriter declared and then closed. If you have got that done, there’s only one more thing we have to do with the FileWriter – Write the File! To achieve this, one would use the write() command. Same as the close command, except that this has a parameter – the text to be written to the file. This should be written after the line where you declared the FileWriter, but before the line where you closed the FileWriter. Putting this anywhere else will result in an error.

For instance, writer.write(“I is the hax”); would print ‘I is the hax’ to the file. Now, you can also write Strings to the file. Just set the parameter to a String. writer.write(filename); would write the path of the file to the file, so that if you opened the file it would say something like “C://Documents and Settings/this.txt”.

However, if you want to make it much cooler, keep reading.

Remember that TextArea you placed on the frame earlier? Here’s where that comes into play. To get the text from a TextArea and put it into a string, you use the same command as you would with a TextField. If you forget what this command is, look in earlier programs where you printed the text from inside a TextField to the system console.

After that, try running the program.

Doesn’t work? It shouldn’t.

We still need to do one more thing to get this to work. Remember the ‘try’ block we added earlier? We have to catch exceptions that the FileWriter might raise, otherwise you might get some errors. To do this, we add a catch() block at the end of the try block. Just like with if/else statements, try/catch statements use the same syntax.

Compare the two:

if(this == that){
//do this
} else {
//do that
}


try{
//try this
} catch (){
//catch that
}

See the similarities?

In between the parentheses after catch, we state the exception that we want to check. For FileWriters, this exception is called IOException – which means Input/Output exception. Just like how you name a String or a TextField or anything else, you also give Exceptions names. The name doesn’t really matter – unless you plan on using it.

So now the try statement should look like this, or something similar:
(I named my IOException “ex”)

try{
FileWriter writer = new FileWriter( filename );
writer.write(“anything you want”);
writer.close();
}catch (IOException ex){
}

If you compile/run the program, it should work. If not, ask me and I will come over and help you. Hope this helps!

~Your one and only Lord and Master Berserkguard,
Protector of the Alliance,
Pwner of the n00bs

Wed March 25: A student-led learning session

Greetings, fellow code monkeys!

Today will be the first day that a member of this class demonstrates a particular technique that he has learned in the course of creating his project. That student is Ryan N., and the programming technique he is going to demonstrate will be how to save a file from within a Java program. File creation and manipulation is an essential tool in any programming language, and it is certainly so in Java, so I will expect your full level of support and cooperation with your classmate in this process.

There is an initial file to download from our account at Box.net. The name of the folder is "RyanNFileSave" and it can be found at this address:

http://www.box.net/shared/jb0u5k2lhh

Please go there now and download this file, and save it to a folder in your Java folder. When we are finished with this lesson, you will be expected to email it to me as an attachment. You are then free to use the time remaining to work on your current projects.

Cheers,
Uncle Paulie

Sunday, March 22, 2009

Monday March 23: you talk, then you type

Greetings, fellow code monkeys!



I have been reviewing your programs, seeing what's working, helping out where there are some difficulties, and generally just getting a peek into where you are heading. I have made some very brief commendations and recommendations for each of you, which I will be sending out by email, possibly today, but more likely it will be tomorrow. They are tailored to your individual progress, to the extent that I could do so. Before we get to that however, there are two tasks that need to be taken care of first:



A) You will all need to make a posting to our discussion group with a subject heading that includes your name, plus the phrase "the comments speak". In the body of this posting, you must use the comments from your program to create a two paragraph description, three complete sentences per paragraph, of what your program does. Later on, when you hand in your programs by email, I will observe how closely your discussion posts match your comments.

Of course, if you have been a little remiss in commenting your program, this assignment is going to be a little more difficult for you to complete. Tell you what: I betcha if you add the comments now while you're creating this latest discussion, your 'umble instructor will be never the wiser for it.



B) When you are done with that operation, you will need to add something similar to your program. Most of your programs include a menuitem called "About"; when clicked on, it pops up a Window which has a Label. The label might already have some default text in it; replace this text with your name, todays date, the name of your program, and a two sentence description of your program, based on the Discussion posting from A) above.



Time permitting, after that you have free reign to continue developing your program :-)



Cheers,
Uncle Paulie

Thursday, March 19, 2009

Thursday March 19: time to p0ny up!

Greetings, fellow code monkeys,

Today you will need to do the following regarding the programs which you have been working on:

A) you will need to make sure that you have adequately COMMENTED all relevant sections of it. In other words, someone else needs to be able to read your code and understand what the heck you are doing

B) You need to be able to demonstrate that you actually have some kind of crude understanding of how the main parts of your program actually work. ESPECIALLY if some of these vital parts involve programming techniques not covered in this class. If you are going to "borrow" some code from elsewhere, at least be decent enought to figure out how it operates

C) Along this line, I will be asking some of you if you would like to demonstrate how some relevant part of your program works...I'm not asking you to give the store away, but if you have something new to offer, something we haven't covered already, I will be looking to share it with the class as a whole.

D) Sharing time will be during some of our classes next week. Be there, or be square.

E) As always, I am requiring you to make a discussion post about what you have accomplished today, problems you've come across etc

F) I will also need the latest version of your program. I need the .java files, not the .class files!

Cheers,
Uncle Paulie

Tuesday, March 17, 2009

Tuesday March 17: Keep 'em coming!

Gentelemen,
I've begun a review of the programs sent to me thus far. The results will be out by this Thursday, which is the next time we meet. In the meantime, just keep on doing as you have been. Just be sure to both A) email me your program before the class ends B) post a discussion about what you've done, issues you've faced, etc etc before the class ends.

cheers,
Uncle Paulie

Monday, March 16, 2009

Monday March 16: keep on keepin' on!

Greetings after your long weekend, fellow code jockeys!

Today you will continue work on the projects which you began last Wednesday, March 11. Here are a few reminders and addendums:

A) If you have done any additional work on this project on your own time, you are to be commended and of course granted some extra credit :-) All you need to do is to IMMEDIATELY send me all code and other related materials by email attachment; in the subject line, just put your name and the phrase "weekend programming"

B) You are free to use any code/programming techniques we have learned through this class

C) If you use anything you discover or have discovered outside of this class, you need to make this clear in your email message when you send me your updated programs at the end of this class.

D) You also need to be able to explain your "discoveries" to the rest of the class; believe me, there's no better way of really understanding something than to have to be able to explain it to a diverse group of people with different levels of skill and enthusiasm.

E) Since this clearly involves extra work on your part, you shall be granted great big heaping helpings of extra credit for doing it successfully, and standard sized amounts for simply making the attempt.

F) In this as in all other endeavors, you are free to bounce ideas off one another, ask each other questions, share resources, etc etc. The class is about you guys after all, not me; I'm just the hired help :-)

Make sure to post a discussion to our group before the end of class, AND email me your updated projects. Both these items should be clearly marked with your name and todays date, which is March 16th.

"its better to ask forgiveness than to beg permission"
Uncle Paulie

Wednesday, March 11, 2009

Wednesday, March 11: unleash the hounds!

Greetings, java-eeeeeeeeeeeeeinated ones!


Today we will be starting a new phase of this class, and it will involve both your own ingenuity and a time limit. You will need to create, develop and update a project of your own design, due by the end of next week March 20 -- just in time for spring. Here are the MINIMUM requirements:



A) You must first of all post a discussion with your name and the working title of your new program in the subject line. The body of the post must include a two or three sentence paragraph describing what this program will do.


B) it cannot be something you've already been developing on the side. Most of you aren't, but for those of you who are, the answer is NO. It has to be something developed specifically for this class.


C) BEFORE THE END OF EACH CLASS, YOU MUST EMAIL ME BY ATTACHMENT ALL FILES TO DO WITH YOUR PROJECT TO MY GMAIL ACCOUNT


D) Your project must be adequately commented at all times. The top of your program better include comments with your name, the brief description of the project mentioned in A) above & the date of this latest build. Other comments included must be a description of what each part of your program is good for, what its doing. If I have to ask, you didn't comment it well enough


E) Additionally, you should be commenting ahead of time, as a way of keeping track of stuff you WANT to develop in your program


F) BTw, all your programs must be application based, no applets need apply.


G) Somewhere along the line, your program needs to make use of AT LEAST the following components:
frames
windows
buttons
textfields
labels
panels
menus


H) Your program is obviously going to have to make use of variables (duh!) you should also be using some collection of variables, such as an array or vector


I) At least half of the coding for your program should be outside the main program itself , IN SEPARATE CLASSES. For the love of humanity, do not make one great big huge hinkin' program that runs to 2000 lines of code -- think MODULAR!


J) Your program should make use of at least one custom method you've created in a separate class


K) Your program should include at least two ways in which an end user can change how the program looks or functions


L) You may work together of course and trade ideas, but each of you is reponsible for producing something.


You have plenty of time and space, and these are only the minimum requirements. Feel free to add in whatever else you can develop


in honor of my youngest one's birthday,
Uncle Paulie

Monday, March 9, 2009

Tues March 10: now that you've done something new and posted about menus...

Now I can start with a request that was put in to "do something about timers" (For my next trick, I'm going to turn water into funk)



A timer is a way of making something happen over and over again, kind of like a loop, only you can turn it on and off at will, set how fast or slow it happens, and determine when it starts. It requires a couple of new import statements; and since you already have your "Menu" programs open, we might as well use them to do this. Here's what you need to do:



A) add the two import statements at the top of your program:

import java.util.Timer;
import java.util.TimerTask;




B) Declare a Timer object and two integers that will be used in controlling when this event starts and how fast it will go:

Timer myClock;//declare Timer object
int countDown = 5000; // delay for 5 sec.
int howOften = 1000; // repeat every sec.




C) create the timer with his line of code...type it in just above the point where the frame shows up (Gumby.show() )

myClock = new Timer();



D) create another menuitem and add it to one of your menus. You can use one you've already declared, such as inky or pinky or blue



E) create another else if statement in your actionPerfomed method, and put in the following code, like so



else if (e.getSource() == inky)
{
myClock.scheduleAtFixedRate(new TimerTask( )
{
public void run( )
{


System.out.println("hello");

}

}, countDown, howOften);

}//end timer stuff

Sunday, March 8, 2009

Monday, March 9: Menus, Do Your Own thing

OK, you should know the drill by now: I want you to use your new knowledge of menus in conjunction with what you already know to do something new. Then I want you to



A) email me your completed program, with your name and the word "menus" in the subject line



B) set up another discussion posting with the same label in the subject line, and explain what it was that you did



th-th-thats all folks!



Uncle Paulie

Monday, March 9: Menus Part four

OK, the last part of this assignment will be failry easy. What I want you to do is to add a Label to this window you've been popping up. Put some text in the label that will let me know that this is YOUR program; please be school appropriate in how you go about this. Here's how I added a label:



right below where I declared the window, I declared the label, like so:

Label gotAnyID;



right below where I created the window, I added this block of code:



gotAnyID = new Label("This label belongs to Mr. LaRue.");

gotAnyID.setBackground(Color.blue);

gotAnyID.setForeground (Color.yellow);

helpWindow.add(gotAnyID);



Cheers,

Uncle Paulie

Monday, March 9: Menus Part three

OK, so by now you have a program that has one menubar, one menu, and one menuitem in that menu that closes the program. Now it's to time to get serious, and do the following:
A) add a second menu

B) add one menuitem to that menu

C) give that item an actionlistener, and put in a new "else if" in your action performed that makes this menu item DO something. In this case, its going to open a window, which is a frame that has not border and no standard controls



Here's how we do that:



1) right below the line that declares a frame

Frame Gumby; //declare Frame

declare a window

Window helpWindow; //declare a window



2) right below the line that declares a menu called "myRoom" declare a menu called OMGhelp



3) You have a long list of menuitems declared: at the end of it but before the ";", add a comma then another menuitem called "about"



OK, so now you've declared everything, now its time to put that stuff in memory. Go to the line that says Gumby.add(exit); and add these two lines:



4)
helpWindow = new Window(Gumby);//window has to be attached to a frame helpWindow.setBounds(600,200,200,200);



5) right below where you created the first menu, you will create the second one and add it to the menubar, like so:

OMGhelp = new Menu("HELP"); //create a Menu

myHouse.add(OMGhelp);//add the second menu to the menubar



6) Just below that, add in the code block which will add the new menuitem called "about" to this new menu, and give it an actionlistener:

about = new MenuItem("ABOUT"); //create a menu item

about.addActionListener(this);//give it a listener

OMGhelp.add(about); //add this menuitem to the new menu



7) Finally, see if you can figure out on your own how to make this menuitem cause that window to appear by adding in another "else if" to the actionPerfomed method



Cheers,

Uncle Paulie