I have a JTable
2 columns, column name and check-box. If the user clicks the check box next to the name of the column that creates a new field for data entry. I wish the unclick check box input field has disappeared.
How can I do that?
My code to add a new field:
headerTable.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if(e.getColumn() >= 0 && e.getFirstRow()>-1){
int id = e.getFirstRow();
String colName = (String)headerTable.getValueAt(e.getFirstRow(), 1);
boolean colValue = (boolean)headerTable.getValueAt(e.getFirstRow(), 2);
System.out.println("Row : " + e.getFirstRow() +
" value :" + headerTable.getValueAt(e.getFirstRow(), 2));
appListener.getColumnId(id);
//create texfield
if(colValue==false){
System.out.println("Delete");
}
jTextField = new JTextField(20);
textField.put(id,jTextField);
if (textField != null && !textField.isEmpty()) {
textField.get(textField.size()-1);
System.out.println("Add");
}
JLabel kolor1name = new JLabel(colName+": ");
operationContent.add(kolor1name,"");
operationContent.add(jTextField, "growy, wrap");
revalidate();
repaint();
}
}
});