Switching applet panels

So, I've picked up development for an existing java applet (not of my creation), and I'm tasked with adding some new functionality to this beast. The top half of the applet is text boxes and whatnot for user input. The bottom half is currently a graph based on calculations using the input data.

Basically, what I'm trying to do is based on a pulldown box (java.awt.choice) swap out the panel that has the graph, and replace it with a text based representation so that users can swap back and forth between numbers and the graph at will.

I've implemented the pulldown box, and the listener is working (and switching the panels), however I'm getting issues with the swap.

Whichever panel is select to appear first shows up correctly (either the text or the graph), when I switch the panels, only the selected background color appears, but nothing else.

I'm at a loss, but that's not really hard since I'm pretty new to this, and I'm probably missing something basic. Here is my ItemListener code.

publicvoid itemStateChanged(ItemEvent ie)

{

if (ie.getStateChange() == ItemEvent.SELECTED)

{

String name = (String) ie.getItem();

if(isGraph)//boolean to show which panel I'm currently showing

{

if(name.equals("Paydate"))

{

panel1.remove(gGraph);

panel1.add(datapanel1, BorderLayout.CENTER);

isGraph =false;

//repaint();

}

}

else

{

if(name.equals("Graph"))

{

panel1.remove(datapanel1);

panel1.add(gGraph, BorderLayout.CENTER);

isGraph =true;

//repaint();

}

}

}

}

[2417 byte] By [kbtibbsa] at [2007-11-27 6:38:45]
# 1
Use a CardLayout. You add both panels to it, then you can tell it which one to display. http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html http://java.sun.com/j2se/1.5.0/docs/api/java/awt/CardLayout.html
hunter9000a at 2007-7-12 18:07:33 > top of Java-index,Java Essentials,New To Java...
# 2
Well, that was simple enough.Thanks very much :-)
kbtibbsa at 2007-7-12 18:07:33 > top of Java-index,Java Essentials,New To Java...