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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -