posted 21 years ago
I have a JTable which is NOT editable, but I do want the background color
to change to indicate that the row has been selected. Notice that I call
setSelectionBackground() but this doesn't do anything.
Thanks...
ItemTable = new JTable( tableDataModel );
ItemTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
ItemTable.setDefaultRenderer( String.class,
new ItemTableCellRender(ItemDisplayData));
ItemTable.setRowSelectionAllowed(true);
ItemTable.setSelectionBackground( Color.BLUE );
ListSelectionModel ItemModel = ItemTable.getSelectionModel();
ItemModel.addListSelectionListener( new ItemSelectionModel() );
ItemTable.setPreferredScrollableViewportSize(new Dimension(500, 650 ));