Update a jPanel
Hi In the following section of code Panel1() is called to create a panel. This section of code contains in 'if' statement and depending on the result a combo box may or may not be created. When updatePanelFromData() is called, I would like to somehow call Panel1 to update it. Does anyone have any suggestions?
public Panel1() {
super();
// Code removed to keep simple
if (data.getType().equals("Type1"))
{
Box = new JComboBox(Option);
panels[2].add(Box);
}
}
public void updatePanelFromData()
{
}
[584 byte] By [
mmidea] at [2007-11-27 2:08:26]

What is updatePanelFromData()going to update?What data is being used for the update, is the data from the ComboBox?Your example is a little vague, please provide a little more detail...
When updatePanelFromData() is called, I would like the JPanel to be updated in such a way that a set of JLables and JTextFields are displayed when the 'if' condition returns true and a different set of JLabels and JTextFields are displayed when the 'if' condition returns false.
if(condition)
{
//create 5 JLabels, then add them
}
else
{
//create 1 JLabel, then add it
}
public Panel1()
{
super();
if(condition)
{
create 5 lables
}
else
{
create 1 lable
}
}
public void updatePanelFromData()
{
}
What do I need to put inside public void updatePanelFromData() to update Panel1 everytime updatePanelFromData() is called?
Thanks