Exception error 2!
In the following code TankPanel calls method WasteWaterPanel() which creates a panel and adds to it a JComboBox where the initial item is 'SSVI'. I would then like to call the method SSVI_ModelParameters() if the selected item in the combo box is 'SSVI'.
The program compiles ok but seems to fail at the indicated line with a NullPointerException error but I cannot work out why. When the program is run without the if statement SSVI is the selected item in the JComboBox.
Code relating to Tank_JPanels[] has been ommitted for clarity.
Thanks
public JPanel Tank_JPanels[] =new JPanel[3];
public JPanel WasteWater_JPanel, SSVI_JPanel;
String Models[] ={"SSVI","GPSX"};
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()
{
WasteWater_JPanel =new JPanel();
WasteWater_JPanel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.gray),"Waste Water Model"));
Tank_JPanels[2].add(WasteWater_JPanel);
JComboBox WasteWaterModel_JComboBox =new JComboBox(Models);
WasteWater_JPanel.add(WasteWaterModel_JComboBox);
}
public TankPanel(){
super();
WasteWaterPanel();
if( WasteWaterModel_JComboBox.getSelectedItem().equals("SSVI"))// Program seems to fail at this point
{
SSVI_ModelParameters();
}
}

