Comment remplir une combobox à partir d'un JTable en Java
rosefransaise
Posted messages
2
Status
Member
-
juliencolin54 Posted messages 238 Status Member -
juliencolin54 Posted messages 238 Status Member -
Hello everyone
My problem is actually that I need to fill a JComboBox with the values from one of the columns of a JTable.
It should be quite simple, but oh well...
Thanks in advance
Configuration: Windows 7 / Firefox 23.0
My problem is actually that I need to fill a JComboBox with the values from one of the columns of a JTable.
It should be quite simple, but oh well...
Thanks in advance
Configuration: Windows 7 / Firefox 23.0
3 answers
Hello,
You can do it like this:
Hoping this helps you, best regards.
--
Software is like sex, it's better when it's free - Linus Torvald
You can do it like this:
/*
** Definition
*/
private JTable table = new JTable();
private JComboBox combo = new JComboBox();
/*
** Initialization of objects
*/
/*
** Retrieving the value at the
** (row_index + 1) column
** (col_index + 1) row
*/
table.getModel().getValueAt(row_index, col_index);
/*
** Adding a value to the JComboBox
*/
combo.addItem(SOMETHING);
Hoping this helps you, best regards.
--
Software is like sex, it's better when it's free - Linus Torvald