• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle more than two combobox

 
Swela Jathar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have 4 combo box and m adding values to combo box depending on previous combo box value.
n when user selects another value in same combo box i just called removeAllItems(); on combo box.so that previous values gets deleted. .it is working for only 2 combo boxes.
but it gives null pointer exception for more than 2 combo box. This is because when i called removeallItems() then actionlister is called automatically. n i hav written query for adding values to that in actionlistener.
so how should i handle these combo boxes??
thanks in advance...
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show some code?
 
Swela Jathar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Greq,

see I have combo boxs for Person Name,Person Id,and Receipt No.

I have added person names to combo in constructor.



Next In ActionListener of first combo box i hav added customer id into 2nd combo box.
like


up to this it is working fine...then according to customer id i wants to select receipt no.
so in actionlistener of 2nd combo box i hav written code like



I got Null pointer exception..


 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where have you initialized combo_receipt_report?
 
Swela Jathar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks maneesh,
I have just added an item like "select report" in constructor...


Main problem is that when i remove items from combo_receipt_report in combo_person_idActionPerformed (LINE NO 4) then actionlistener of combo_receipt_report is called.thats why it is giving null pointer exception..

Thanks...
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That indicates a problem in the actionListener code of combo_receipt_report. Based on your other actionListeners, I am thinking you are making a call to: in the actionListener of that combo. Instead you should add a null check. When all the items are removed, there is no item to select - so the getSelectedItem() will return null.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swela Jathar wrote:thanks maneesh,
I have just added an item like "select report" in constructor...


Main problem is that when i remove items from combo_receipt_report in combo_person_idActionPerformed (LINE NO 4) then actionlistener of combo_receipt_report is called.thats why it is giving null pointer exception..

Thanks...


I don't think you are understanding what I am saying. Have you initialized combo_receipt_report? Something like combo_receipt_report=new JComboBox()
 
Swela Jathar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya..i hav initialized it...n then added item to it..
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the code you have posted till now it is difficult to say what's going wrong. You can help us help you better by posting a SSCCE code. Please do take out time to click the SSCCE link to find out what it really means.
 
Andrew flexdeveloper
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I also face the same problem.

Can you please help me in details?
 
Swela Jathar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maneesh,

can you show me some another example which handles more than three combo boxes?
Thanks..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic