Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting text length in editable JComboBox? 1

Status
Not open for further replies.

GDameron

Programmer
Aug 8, 2003
39
US
Is there a way to limit the number of characters that may be typed in an editable JComboBox, analogous to setting up a Document model for a JTextField?

WGD
 
If memory serves, the default editing component for the combo is a JTextField anyway, so you could do something like :-
Code:
((JTextField)combo.getEditor().getEditorComponent()).setDocument(<document object>);
.. and use the document to limit the length as yo do for your ordinary JTextFields.

I've not tried this out, so apologies if it doesn't work.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top