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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -