• 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

JComboBox focus

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with an editable JComboBox.
When I press my EDIT button, but doesn't do any editing in the JComboBox , and then my OK button I want to get the item in the JComboBox. It is ok when an item in the list is visible but if i have an item which i have put there myself, the call getSelectedItem returns null. I have to klick in the field to get the cursor in it and then its ok.
What i want is some method to get the cursor in there.
I have tried requestFocus but it doesn't work.
please help
/Stefan
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It has to be selected for getSelectedItem() to return anything but null. You might look into setSelectedItem() and setSelectedIndex().
 
Stefan Jansson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I called setSelectedItem() with the previus value before I called getSelectedItem() and it works fine. :-D
 
reply
    Bookmark Topic Watch Topic
  • New Topic