Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / May 2004

Tip: Looking for answers? Try searching our database.

JComboBox limit to list

Thread view: 
Josef Garvi - 29 May 2004 16:54 GMT
How can I make my editable Combo box limited to the items in the list (like
when using the LimitToList property in MS Access)?
Not just making it highlight matching items in the list, but also refusing
input that doesn't match the list entries?

Signature

Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty

ak - 30 May 2004 01:27 GMT
> How can I make my editable Combo box limited to the items in the list (like
> when using the LimitToList property in MS Access)?
> Not just making it highlight matching items in the list, but also refusing
> input that doesn't match the list entries?
what is "Combo box" ? I know only JComboBox and Choice.

if you use JComboBox:
1) get Document of ComboBoxEditor Component:
JTextField jtf = (JTextField)JComboBox#getEditor()#getEditorComponent();
Document doc = jtf.getDocument();

2) use this Document to refuse unmatched input.

Signature

http://uio.dev.java.net
http://reader.imagero.com

Josef Garvi - 30 May 2004 12:05 GMT
> what is "Combo box" ? I know only JComboBox and Choice.

Yes, I'm thinking of JComboBox or a derived class of some sort.

> if you use JComboBox:
> 1) get Document of ComboBoxEditor Component:
> JTextField jtf = (JTextField)JComboBox#getEditor()#getEditorComponent();
> Document doc = jtf.getDocument();
>
> 2) use this Document to refuse unmatched input.

Didn't understand how to do this....
Document allow two listeners:
  - DocumentListener
  - UndoableEditListener

...but I don't se any way of cancelling the events in either of them.

Anyway, I did find code that does the job on the following page:
http://www.tutorials.de/tutorials75713.html

Signature

Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty

ak - 30 May 2004 13:30 GMT
> > 2) use this Document to refuse unmatched input.
>
> Didn't understand how to do this....
> Document allow two listeners:
>    - DocumentListener
>    - UndoableEditListener
you should write your own Document and override method insertString();

Signature

http://uio.dev.java.net
http://reader.imagero.com

Josef Garvi - 30 May 2004 13:30 GMT
> you should write your own Document and override method insertString();

Thanks.

Signature

Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty

Adam - 31 May 2004 07:23 GMT
> How can I make my editable Combo box limited to the items in the list (like
> when using the LimitToList property in MS Access)?
> Not just making it highlight matching items in the list, but also refusing
> input that doesn't match the list entries?

Isn't that a job for non-editable ComboBox?

Adam


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.