| Author |
How to handle more than two combobox
|
Swela Jathar
Greenhorn
Joined: Aug 19, 2011
Posts: 22
|
|
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
Joined: Oct 24, 2010
Posts: 530
|
|
|
Can you show some code?
|
Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
|
 |
Swela Jathar
Greenhorn
Joined: Aug 19, 2011
Posts: 22
|
|
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
Joined: Jul 26, 2007
Posts: 8441
|
|
|
Where have you initialized combo_receipt_report?
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Swela Jathar
Greenhorn
Joined: Aug 19, 2011
Posts: 22
|
|
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
Joined: Oct 16, 2003
Posts: 927
|
|
|
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.
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8441
|
|
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
Joined: Aug 19, 2011
Posts: 22
|
|
|
ya..i hav initialized it...n then added item to it..
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8441
|
|
|
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
Joined: Aug 04, 2011
Posts: 7
|
|
Hi friends,
I also face the same problem.
Can you please help me in details?
|
Flex Development | Flex Developer in India
|
 |
Swela Jathar
Greenhorn
Joined: Aug 19, 2011
Posts: 22
|
|
Hi Maneesh,
can you show me some another example which handles more than three combo boxes?
Thanks..
|
 |
 |
|
|
subject: How to handle more than two combobox
|
|
|