Allain Lalonde Allain Lalonde - 1 year ago 88
Java Question

How do I get InputVerifier to work with an editable JComboBox

I've got an

with a custom
set to limit MaxLength when it's set to editable.

The verify method never seems to get called.

The same verifyer gets invoked on a

What might I be doing wrong?

Answer Source

I found a workaround. I thought I'd let the next person with this problem know about.

Basically. Instead of setting the inputVerifier on the ComboBox you set it to it's "Editor Component".

JComboBox combo = new JComboBox();
JTextField tf = (JTextField)(combo.getEditor().getEditorComponent());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download