• 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

Getting Lost Focus from JComboBox

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a interface
which has a textfield and combobox and
a JTable
on lost focus of combobox i want to
populate my JTable
my code
jcmbBox.addFocusListener(new FocusAdapter()
{
public void focusLost(FocusEvent e)
{
JoptionPane.showMessageDialog(null,"Lost Focus");
}
});
i am testing it by using a MessageBox as above
MessageBox is not firing
can anyone come with a handy solution
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, behind a JComboBox, there are two components,
a renderer and an editor. So you have to add your Listener to the editor of the JComboBox. You can get it with:
yourComboBox.getEditor().getEditorComponent();
Then you can add your listener to this component and not to your ComboBox.
Hope this works
Rene
 
Udaya Bascar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
myComboBoxName.getEditor().getEditorComponent().addFocusListener(new FocusAdapter()...

is it ok
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it looks good. And does it work?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic