Wednesday, April 1, 2009

Tues April 1: Java Swing Tabbed Browsing, part Two

OK, so maybe you're thinking to yourself: this is cool but how do I make more than one tab? If I can't do that, it defeats the whole purpose of having tabs!



Very tru, O impatient ones, but there is a simple solution: create a button that calls the method that made the first tab. Try to see if you can figure that out on your own (I'm betting some of you already have). Try it yourself, and if you can't do it for real the solution is way down at the end of this posting



Cheers,

Uncle Paulie





















































































See, I told you I would give you a solution...now could you try doing this yourself next time?



Add this to your constructor:

Pinky = new JButton("New Tab");
Pinky.setBounds(0,0,130,20);
Pinky.addActionListener(this);
ButtonsAndText.add(Pinky);


Add this to your actionPerformed method

if (e.getSource( ) == Pinky)
{
makeTab( ); // make method call
}


No comments:

Post a Comment