<p>I've got an <code>JComboBox</code> with a custom <code>inputVerifyer</code> set to limit MaxLength when it's set to editable.</p>

<p>The verify method never seems to get called.<br>
The same verifyer gets invoked on a <code>JTextField</code> fine.</p>

<p>What might I be doing wrong?</p>

[{'answer_id': 54614, 'author': 'Tom Hawtin - tackline', 'author_id': 4725, 'author_profile': 'https://Stackoverflow.com/users/4725', 'pm_score': 1, 'selected': False, 'text': '<p>Show us a small section of your code.</p>\n\n<pre><code>package inputverifier;\n\nimport javax.swing.*;\n\n    class Go {\n    public static void main(String[] args) {\n        java.awt.EventQueue.invokeLater(new Runnable() { public void run() {\n            runEDT();\n        }});\n    }\n    private static void runEDT() {\n        new JFrame("combo thing") {{\n            setLayout(new java.awt.GridLayout(2, 1));\n            add(new JComboBox() {{\n                setEditable(true);\n                setInputVerifier(new InputVerifier() {\n                    @Override public boolean verify(JComponent input) {\n                        System.err.println("Hi!");\n                        return true;\n                    }\n                });\n            }});\n            add(new JTextField());\n            setDefaultCloseOperation(EXIT_ON_CLOSE);\n            pack();\n            setVisible(true);\n        }};\n    }    \n}\n</code></pre>\n\n<p><a href="http://bugs.sun.com" rel="nofollow noreferrer">Looks like it\'s a problem with JComboBox being a composite component.</a> I\'d suggest avoiding such nasty UI solutions.</p>\n'}, {'answer_id': 54799, 'author': 'Allain Lalonde', 'author_id': 2443, 'author_profile': 'https://Stackoverflow.com/users/2443', 'pm_score': 4, 'selected': True, 'text': '<p>I found a workaround. I thought I\'d let the next person with this problem know about. </p>\n\n<p>Basically. Instead of setting the inputVerifier on the ComboBox you set it to it\'s "Editor Component". </p>\n\n<pre><code>JComboBox combo = new JComboBox();\nJTextField tf = (JTextField)(combo.getEditor().getEditorComponent());\ntf.setInputVerifier(verifyer);\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/54567', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2443/']