Share

Pounder Java GUI Testing Utility

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Trouble With JTable

You are viewing a single message from this topic. View all messages.

  1. 2003-04-16 14:45:55 UTC
    Hi Matthew,

    Thanks for replying!
    First off, I am using the SUN 1.4.1_02 VM.
    As far as I can tell, JTable works as follows:

    JTable has the concept of a TableCellRenderer which is used to get a component to paint a given cell when it's not in edit mode (one method, getTableCellRendererComponent, returns the component).
    TableCellEditor is a similar scheme used for getting a component to edit a given cell.

    JTable itself is a CellEditorListener, which fires events when the editing of a table cell has stopped or been cancelled. It also maintains two HashMaps, one for default cell editors and one for default cell renderers, which are both stored against class (e.g. the default renderer for String.class may be a JLabel, and the default editor may be a JTextField).
    If you look at the two methods getCellEditor(row,column) and getCellRenderer(row,column) you will see that they first check the TableColumn for the input column index to see if there's a specific renderer/editor registered to it, if not, the default value is taken from one of the HashMaps.

    Normally you can put a cell into edit mode clicking in it - the JTable then stops rendering the cell with the renderer component and shows the cell editor component instead.

    I'm using a boolean cell renderer which returns a JCheckBox as its editing component. The cell renderer also returns a checkbox component, albeit readonly.

    I hope that gives you a feel for what's going on / enough information to reproduce. I'll post the stack trace when I get a chance to run the test again.

    Gus.
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.