K
KLD
Within my table model , two of the columns contain a JComboBox dropdown of
choices. I want to make one of the JComboBoxes editable, jcb_Status (so you
can select from the dropdown, or type text in the field). I can only seem
to get the first row in the table model to be editable, and then it does not
put the drop down list on the subsequent items in the combobox.
Winder_Table_Model _Winder_Table_Model = null;
public void Display_Pattern_Table()
{
_Winder_Table_Model = new Winder_Table_Model();
jtbl_Positions.setModel(_Winder_Table_Model);
JComboBox jcb_Status = new JComboBox();
// I tried this, it will only make the first item editable.
// jcb_Status.setEditable(true);
_DB_Roll_status_dcd.Populate_JComboBox(jcb_Status);
// I thought maybe the setEditable only applied to the selected index and
tried this.
// It does not work either.
// int i = jcb_Status.getItemCount();
// for (int j=0 ; j < i-1 ; j++)
// {
// jcb_Status.setSelectedIndex(j);
// jcb_Status.setEditable(true);
// }
jcb_Status.setSelectedIndex(0);
JComboBox jcb_Defect = new JComboBox();
_DB_Roll_reason_cd.Populate_JComboBox(jcb_Defect);
jcb_Defect.setSelectedIndex(-1);
jtbl_Positions.getColumnModel().getColumn(6).setCellEditor(new
DefaultCellEditor(jcb_Status));
jtbl_Positions.getColumnModel().getColumn(7).setCellEditor(new
DefaultCellEditor(jcb_Defect));
// Set up the notes column cell renderer
jtbl_Positions.getColumnModel().getColumn(10).setCellRenderer(new
Note_Cell_Renderer());
// Don't allow multiple row selections
jtbl_Positions.getSelectionModel().setSelectionMode(ListSelectionModel.SINGL
E_SELECTION );
jtbl_Positions.getTableHeader().setReorderingAllowed(false);
jtbl_Positions.getTableHeader().setResizingAllowed(false);
Winder_Table_Model.Set_Column_Widths(jtbl_Positions);
}
choices. I want to make one of the JComboBoxes editable, jcb_Status (so you
can select from the dropdown, or type text in the field). I can only seem
to get the first row in the table model to be editable, and then it does not
put the drop down list on the subsequent items in the combobox.
Winder_Table_Model _Winder_Table_Model = null;
public void Display_Pattern_Table()
{
_Winder_Table_Model = new Winder_Table_Model();
jtbl_Positions.setModel(_Winder_Table_Model);
JComboBox jcb_Status = new JComboBox();
// I tried this, it will only make the first item editable.
// jcb_Status.setEditable(true);
_DB_Roll_status_dcd.Populate_JComboBox(jcb_Status);
// I thought maybe the setEditable only applied to the selected index and
tried this.
// It does not work either.
// int i = jcb_Status.getItemCount();
// for (int j=0 ; j < i-1 ; j++)
// {
// jcb_Status.setSelectedIndex(j);
// jcb_Status.setEditable(true);
// }
jcb_Status.setSelectedIndex(0);
JComboBox jcb_Defect = new JComboBox();
_DB_Roll_reason_cd.Populate_JComboBox(jcb_Defect);
jcb_Defect.setSelectedIndex(-1);
jtbl_Positions.getColumnModel().getColumn(6).setCellEditor(new
DefaultCellEditor(jcb_Status));
jtbl_Positions.getColumnModel().getColumn(7).setCellEditor(new
DefaultCellEditor(jcb_Defect));
// Set up the notes column cell renderer
jtbl_Positions.getColumnModel().getColumn(10).setCellRenderer(new
Note_Cell_Renderer());
// Don't allow multiple row selections
jtbl_Positions.getSelectionModel().setSelectionMode(ListSelectionModel.SINGL
E_SELECTION );
jtbl_Positions.getTableHeader().setReorderingAllowed(false);
jtbl_Positions.getTableHeader().setResizingAllowed(false);
Winder_Table_Model.Set_Column_Widths(jtbl_Positions);
}