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 / June 2005

Tip: Looking for answers? Try searching our database.

fill up comboboxes in a JTable

Thread view: 
san - 17 Jun 2005 12:57 GMT
Hi
I have a JTable, which has in column 1-3 comboboxes. The JTable has a
model. I get the values in the combobox from a database.
Now my question: Is it possible to fill up the comboboxes (addItem) in
the tableModel, or do I have to write a combobox model?
The JTable Model doesn't know the view, where the combobox is defined.
But if the JTable Model would know the view, it would be really easy to
fill up the combobox out from the JTable model if I would make combobox
protected. Is this an ugly solution?
Please give me some advices
Thanks
Sandy
Chris Smith - 17 Jun 2005 14:21 GMT
> I have a JTable, which has in column 1-3 comboboxes. The JTable has a
> model. I get the values in the combobox from a database.
[quoted text clipped - 4 lines]
> fill up the combobox out from the JTable model if I would make combobox
> protected. Is this an ugly solution?

Can you post some sample code to make this clearer.

As general advice, you definitely don't want your table model class to
know anything about GUI classes like JComboBox.  You would need to
handle the translation from the data model to GUI components elsewhere.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Liz - 20 Jun 2005 19:39 GMT
creating a combobox model will be a overkill. Just additem should
sufficient, unless you would like to resuse the combobox data in
comboxboxes through out your application.

JTable doesn't have the feature of filling a combobox with a database
query. In my experience, I have tried to use free QuickTable java
component (http://quicktable.org) which is an implementation on top of
JTable , but hides all the complexities and allows to use the JTable
methods.

In quicktable you need to just make one call, to bind a column with a
database query combobox.

quicktable.getColumn(0).setBoundSql("select department from company");

No need to create any cellrenderer ir editor.

API help can be found at
http://quicktable.org/doc/quick/dbtable/Column.html#setBoundSql(java.lang.String)


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.