Thread: JComboBoxes
View Single Post
  #1 (permalink)  
Old 07-26-2008, 02:52 PM
Keerti Keerti is offline
Member
 
Join Date: Jul 2008
Posts: 5
Keerti is on a distinguished road
JComboBoxes
Hi all
I am working on a UI which has 2 tabs.In the class for the first tab I declare and initialize an array of JComboBoxes.
public class tabone{
protected JComboBox[] combolist = new JComboBox[3];
public addComponents(){
for(int i=0;i<4;i++)
{
this.combolist[i] = new JComboBox();
}
//set name for JcomboBoxes
combolist[0].setName("combo1");
combolist[1].setName("combo2");
combolist[2].setName("combo3");
combolist[3].setName("combo4");
}
}

In the class for the second Tab I want to access the last two JComboBoxes.
These two claases are in the same package.
public class tabtwo extends tabone{
String name = combolist[2].getName();
This line throws up an error:Exception in thread "main" java.lang.NullPointerException

Can someone please tell why i am getting this error.
or
How should I access the JComboBoxes in the class for tabtwo?
Reply With Quote
Sponsored Links