Thursday, April 2, 2009

Friday April 3: Java Swing Tabbed Browsing part Six

Alrighty then, for our last trick together before you surge ahead on your own, why don't we make an "Add to Favorites" type component? This would be something that would allow you to add additional addresses to your ComboBox. Here's what I did:

A) I declared a new button:
JButton Bravo;

B) created it in memory and added to the program, giving it an actionlistener:
Bravo = new JButton("Add 2 Faves");
Bravo.setBounds(460,0,130,20);
Bravo.addActionListener(this);
ButtonsAndText.add(Bravo);

C) Add another "else if" to our actionPerformed:
else if (e.getSource() == Bravo)
{
addFaves(); // make method call
}

D) create the new method that is being called

System.out.println("everybody, do the monkey!");
webURL.addElement(WhereTo.getText()); //add to vector
myWebPlaces = new JComboBox(webURL); //reload vector to combobox

That should about do it, And once you've mastered that, you know what I'm looking for:

1) add something you already know about to this program

2) make a posting about what you did today while working with this program

Have a helluva weekend,
Uncle Paulie

No comments:

Post a Comment