Action listener not working

Hi

In the following piece of code TankPanel() is called to creates the JPanel SSVI_JPanel or GPSX_JPanel depending on the selected item in the JComboBox WasteWaterModel_JComboBox.

I have declared an action listener on the JComboBox in WasteWaterPanel(). In the bottom section of code that responds to the action I would like to remove the JPanel GPSX_JPanel and then call SSVI_ModelParameters(); to add SSVI_JPanel. My action listener is not working though as I cannot even print the statement.

Can anyone suggest why?

Thanks

public JPanel Tank_JPanels[] =new JPanel[3];

public JPanel WasteWater_JPanel, GPSX_JPanel, SSVI_JPanel;

String Models[] ={"GPSX","SSVI"};

public JComboBox WasteWaterModel_JComboBox =new JComboBox(Models);

publicvoid GPSX_ModelParameters()

{

GPSX_JPanel =new JPanel();

GPSX_JPanel.setBorder(BorderFactory.createTitledBorder(

BorderFactory.createLineBorder(Color.gray),"GPSX Model Parameters"));

Tank_JPanels[2].add(GPSX_JPanel);

}

publicvoid SSVI_ModelParameters()

{

SSVI_JPanel =new JPanel();

SSVI_JPanel.setBorder(BorderFactory.createTitledBorder(

BorderFactory.createLineBorder(Color.gray),"SSVI Model Parameters"));

Tank_JPanels[2].add(SSVI_JPanel);

}

publicvoid WasteWaterPanel()

{

if(typeBox.getSelectedItem().equals("Waste Water Treatment"))

{

Tank_JPanels[2] =new JPanel();

Tank_JPanels[2].setBorder(BorderFactory.createTitledBorder(

BorderFactory.createLineBorder(Color.gray),"Tank Property"));

WasteWater_JPanel =new JPanel();

WasteWater_JPanel.setBorder(BorderFactory.createTitledBorder(

BorderFactory.createLineBorder(Color.gray),"Waste Water Model"));

Tank_JPanels[2].add(WasteWater_JPanel);

WasteWaterModel_JComboBox.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent evt){

WasteWaterModel_JComboBox(evt);}

});

WasteWater_JPanel.add(WasteWaterModel_JComboBox);

}

}

publicvoid WasteWaterPanel()

{

if(typeBox.getSelectedItem().equals("Waste Water Treatment"))

{

Tank_JPanels[2] =new JPanel();

Tank_JPanels[2].setBorder(BorderFactory.createTitledBorder(

BorderFactory.createLineBorder(Color.gray),"Tank Property"));

WasteWater_JPanel =new JPanel();

WasteWater_JPanel.setBorder(BorderFactory.createTitledBorder(

BorderFactory.createLineBorder(Color.gray),"Waste Water Model"));

Tank_JPanels[2].add(WasteWater_JPanel);

WasteWaterModel_JComboBox.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent evt){

WasteWaterModel_JComboBox(evt);}

});

WasteWater_JPanel.add(WasteWaterModel_JComboBox);

}

}

public TankPanel(){

super();

WasteWaterPanel();

if(WasteWaterModel_JComboBox.getSelectedItem().equals("GPSX"))

{

GPSX_ModelParameters();

}

if(WasteWaterModel_JComboBox.getItemAt(0).equals("SSVI"))

{

SSVI_ModelParameters();

}

}

publicvoid WasteWaterModel_JComboBox(ActionEvent evt){

if(WasteWaterModel_JComboBox.getSelectedItem().equals("SSVI"))

{

System.out.println("THIS PRINTS IF ACTION LISTENER WORKING!");

WasteWater_JPanel.remove(GPSX_JPanel);

SSVI_ModelParameters();

WasteWater_JPanel.repaint();

}

}

[5886 byte] By [mmidea] at [2007-11-27 2:26:12]
# 1

can I give you a small tip? the overwhelming majority of java coders use a naming convention that says class names should begin with an uppercase letter, and variable and method names with a lowercase letter. not following this convention makes your code look like it's doing something that it might not actually be doing. and it's unclear if this code is all part of one class or not, either. re-post, making your code more readable

georgemca at 2007-7-12 2:35:13 > top of Java-index,Java Essentials,New To Java...