C
Chris
Hello,
I did create a jTable using cell editor in order to have one column as
a jComboBox. Everything works fine, bu I have a limitation.
In the extract example below, the column #2 was defined as jComboBox
with values from 0 to 4.
When I populate the jTable, for each row in column 2, I can select the
values from jCombo.
Here is my question: I need to have different content of jComboBox for
each row.
e.g. :
row #1 has values from 0 to 4, selected from jComboBox / this
jComboBox should display only values 0 to 4
row #2 has values from 5 to 10 , selected from jComboBox / this
jComboBox should display only values 5 to 10
row #3 has values from 11 to 15,f selected from jComboBox / this
jComboBox should display only values 11 to 15...
Is that possible in the way I did start? How should I dynamically
create and populate jComboBox-es to have different content for each
row of jTable and how to associate these jComboBox to jTable? Could
you please let me find out how should I continue for my situation.
Thanks,
Chris
....
Vector descriptionList = new Vector();
JTable jTable1
Object obj;
for (int i = 0; i < 4; i++)
descriptionList.add(new Integer(i));//add some values
JComboBox myJComboBox = new JComboBox(descriptionList);
TableCellEditor myCellEditor = new DefaultCellEditor(myJComboBox );
TableColumnModel myCellModel = jTable1.getColumnModel();
TableColumn myColumn = myCellModel.getColumn(2);//column # as jCombo
myColumnn.setCellEditor(myCellEditor);
....
//cellsTab & columnNames are defined and populated
jTable1 = new JTable(cellsTab, columnNames);
I did create a jTable using cell editor in order to have one column as
a jComboBox. Everything works fine, bu I have a limitation.
In the extract example below, the column #2 was defined as jComboBox
with values from 0 to 4.
When I populate the jTable, for each row in column 2, I can select the
values from jCombo.
Here is my question: I need to have different content of jComboBox for
each row.
e.g. :
row #1 has values from 0 to 4, selected from jComboBox / this
jComboBox should display only values 0 to 4
row #2 has values from 5 to 10 , selected from jComboBox / this
jComboBox should display only values 5 to 10
row #3 has values from 11 to 15,f selected from jComboBox / this
jComboBox should display only values 11 to 15...
Is that possible in the way I did start? How should I dynamically
create and populate jComboBox-es to have different content for each
row of jTable and how to associate these jComboBox to jTable? Could
you please let me find out how should I continue for my situation.
Thanks,
Chris
....
Vector descriptionList = new Vector();
JTable jTable1
Object obj;
for (int i = 0; i < 4; i++)
descriptionList.add(new Integer(i));//add some values
JComboBox myJComboBox = new JComboBox(descriptionList);
TableCellEditor myCellEditor = new DefaultCellEditor(myJComboBox );
TableColumnModel myCellModel = jTable1.getColumnModel();
TableColumn myColumn = myCellModel.getColumn(2);//column # as jCombo
myColumnn.setCellEditor(myCellEditor);
....
//cellsTab & columnNames are defined and populated
jTable1 = new JTable(cellsTab, columnNames);