Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Binding a JTable column to a bound combobox

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NetBeans makes it easy to create a Jtable and bind it to a table from an SQL database, thanks to TopLink Essentials.

...But how do I bind a column in the database to a particular table?

Let's say you have a table called Employees. Each row contains a unique ID#, a name (e.g. John Smith) and the ID of the employee's department. You may edit the table to change any of this information.

This table has been bound to a Jtable called EmployeesTable.

I would like to edit each employee's department not as a number but as a combobox populated with the department names (Sales, Marketing, etc.), pulled from another table (called Departments, let's say). When the user selects the department name, the ID# of the department should be fed back to the column in that row of the table.

Binding an SQL table to a JComboBox is trivial, thanks to the BeansBinding tools. However, I haven't figured out how to bind *all* entries in a column of a JTable that way.

I've been trying to figure this out since October, without success. *Any* advice would be appreciated. Although I'm not new to programming, I am new to Java. Thank you for your time.
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You will have to use AbstractTableModel and ListSelectionListener for this.

Maki Jav
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic