java - How do I lose focus on a JComboBox? -
i have jcombobox key listener.
when hit <enter>, fire off action, and need to lose focus on jcombobox!
to focus on it, can jcomboboxobject.grabfocus();
but doing transferfocus() focus next element (i don't care focus goes, away combo box) not work.
doing grabfocus() combo box works, seems pretty annoying hack me. there better solution?
i can suggest first use
.getnextfocusablecomponent()
and use the
.requestfocusinwindow()
that means implementing this,
jcombobox.getnextfocusablecomponent().requestfocusinwindow();
one important note .getnextfocusablecomponent() has become obsolete can work better, can use if have other solution, prefer not using this.
Comments
Post a Comment