<Swing Dev> Selecting cells in jtable

Pavel Porvatov pavel.porvatov at oracle.com
Thu Mar 15 10:15:02 UTC 2012


Hi Sanjaya,

Take a look at the javadoc for the JTable#setCellSelectionEnabled method:

      * Sets whether this table allows both a column selection and a
      * row selection to exist simultaneously. When set,
      * the table treats the intersection of the row and column selection
      * models as the selected cells. Override 
<code>isCellSelected</code> to
      * change this default behavior

So, for your purpose you have to override isCellSelected....

Regards, Pavel
> Hi,
>     I have a jtable with 5 rows and 5 columns.I want to select the
> following diagonal cell when the enter key is pressed.Initially 0,0
> cell is selected.(1,1),(2,2),(3,3),(4,4) cells should be selected when
> the enter key is pressed 4 times consecutively.How can I do this?
>
> thank you
> Sanjaya




More information about the swing-dev mailing list