Edit a Boolean in JTable

From: Bart_D (bart_at_cleaned.be)
Date: 03/31/04


Date: 31 Mar 2004 08:30:43 -0800

Hello,

hope somebody can help me.

I have a JTable with Boolean values in a column. The JTable gets it's
values from a Vector (for which I have extended the
AbstractTableModel)

I am able to "edit" this column (set Boolean cell to true or false).
But the problem is : when I put one row to "true" all the other must
be set to false (this value also must be saved in a Vector).

Does anyone know how I can do this ? I need some kind of
"valuechanged" for the column with the Booleans.

I can check if the value is a Boolean with : (the table is called
setTable and the Boolean is in the third column)

int i;
for (i = 0;i<setTable.getRowCount();i++) {
if (((Boolean)setTable.getValueAt(i, 2)).equals(Boolean.TRUE))
{
    System.out.println("true");
}

If i can check when a value in the third column (the Boolean column)
is changed, I can set all the values to false, except the one just
clicked.

Hope somebody can help me.

Bart



Relevant Pages

  • Re: check-boxes in JTable
    ... public TableCellRenderer getCellRenderer(int row, int column) { ... TableColumn tableColumn = getColumnModel.getColumn; ... boolean isSelected, boolean hasFocus, int row, int column) { ... return editorComponent; ...
    (comp.lang.java.gui)
  • Re: identity...... Was: The wisdom of the object mentors
    ... // this is it's implementation/mapping from a hidden domain of {int x int} ... I'd say that the set of all propositions is language defined behavior or ... Boolean object has no place to keep the class identity. ... bool IsBool1() ...
    (comp.object)
  • Re: Design Questions re Subclassing
    ... public AgeRange(int firstAge, int secondAge) { ... public boolean between(boolean includesLow, int input, boolean ... >> really digested the proper use of Generics yet. ... >> You raise a good point in questioning whether TreeSet should be extended ...
    (comp.lang.java.programmer)
  • Re: KeyEvent consume() not working on JTextField, what am I doing wrong?
    ... public static final int YEAR_1 = 0; ... private boolean keyPressed_actionPerformed{ ... public void nextPosition(int intKeyCode, int intCharPos) { ... String strTempNewValue; ...
    (comp.lang.java.help)
  • debugger an eternal mystery (reload)
    ... boolean barFlag = true; ... int facesNum; ... String imagePieces, str, imagination; ... public void init() { ...
    (comp.lang.java.help)