• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on using getSelectedItem() method in JCombobox to retrieve values

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am at the point in the project where I am trying to use JCombobox to populate Unique Carrier/Origin/Dest values and have suceeded displaying it on the GUI. Next I when I click on the search button I want to capture the values of Carrier/Origin/Dest as selected by the user and pass it eventually to the CriteriaFind Method. This is where I get a Null Pointer Exception
Here is the code I am using
//jcbCarrier1 is the combobox for the Carrier field
//jbSearch is the Search button that implements an action
//listener

class SearchListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
findValue[1] =
(String)jcbCarrier1.getSelectedItem());
//Null pointer exception above on findValue[1]
System.out.println(" SearchListener value "
+ findValue[1]);
}
}
What am I doing wrong here, or should I be doing it some other way. Any help would be much appreciated
Regards
Charu
 
reply
    Bookmark Topic Watch Topic
  • New Topic