nhocgirl0105
Grünschnabel
Hallo zusammen
Ich habe JCheckBox in einer JTable hinzugefügt. Das Problem ist, dass das Hacken der Checkbox immer gesetzt/nicht gesetzt wird, egal wenn es eine mouseClicked oder mouseReleased... Event. Ich möchte aber nur, dass das Checkbox auf mouseClicked reagiert. Kann jemand mir helfen? Danke vielmals.
Gruss
Tannie
public MyTableModel() {
//insert column titles
columnTittles.add("");
columnTittles.add("Lines' ID");
columnTittles.add("Lines' Customer Texts");
}
public int getColumnCount() {
return columnTittles.size();
}
public int getRowCount() {
return rowDataLines.size();
}
public Object getValueAt(int rowIndex, int columnIndex) {
return rowDataLines.get(rowIndex).get(columnIndex);
}
public String getColumnName(int columnIndex) {
return columnTittles.get(columnIndex).toString();
}
/**
* JTable uses this method to determine the default renderer/editor
* for each cell. If this method didn't be implemented, then the first column
* would contain text ("true"/"false"), rather than a checkbox.
* @see javax.swing.table.AbstractTableModel#getColumnClass(int)
*/
public Class getColumnClass (int columnIndex) {
return getValueAt(FIRST_ROW, columnIndex).getClass();
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
boolean isEditable = false;
if (columnIndex == 0) {
isEditable = true;
}
return isEditable;
}
public void setValueAt(Object value, int rowIndex, int columnIndex){
Vector<Object> oldVectorValue = rowDataLines.get(rowIndex);
oldVectorValue.set(columnIndex, value);
rowDataLines.set(rowIndex, oldVectorValue);
fireTableCellUpdated(rowIndex, columnIndex);
}
Ich habe JCheckBox in einer JTable hinzugefügt. Das Problem ist, dass das Hacken der Checkbox immer gesetzt/nicht gesetzt wird, egal wenn es eine mouseClicked oder mouseReleased... Event. Ich möchte aber nur, dass das Checkbox auf mouseClicked reagiert. Kann jemand mir helfen? Danke vielmals.
Gruss
Tannie
public MyTableModel() {
//insert column titles
columnTittles.add("");
columnTittles.add("Lines' ID");
columnTittles.add("Lines' Customer Texts");
}
public int getColumnCount() {
return columnTittles.size();
}
public int getRowCount() {
return rowDataLines.size();
}
public Object getValueAt(int rowIndex, int columnIndex) {
return rowDataLines.get(rowIndex).get(columnIndex);
}
public String getColumnName(int columnIndex) {
return columnTittles.get(columnIndex).toString();
}
/**
* JTable uses this method to determine the default renderer/editor
* for each cell. If this method didn't be implemented, then the first column
* would contain text ("true"/"false"), rather than a checkbox.
* @see javax.swing.table.AbstractTableModel#getColumnClass(int)
*/
public Class getColumnClass (int columnIndex) {
return getValueAt(FIRST_ROW, columnIndex).getClass();
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
boolean isEditable = false;
if (columnIndex == 0) {
isEditable = true;
}
return isEditable;
}
public void setValueAt(Object value, int rowIndex, int columnIndex){
Vector<Object> oldVectorValue = rowDataLines.get(rowIndex);
oldVectorValue.set(columnIndex, value);
rowDataLines.set(rowIndex, oldVectorValue);
fireTableCellUpdated(rowIndex, columnIndex);
}