Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By camickr

Thread: JTable selecting single row problem

  1. #1
    ContoNick is offline Member
    Join Date
    Dec 2011
    Location
    Croatia,Zagreb
    Posts
    24
    Rep Power
    0

    Default JTable selecting single row problem

    I cant find out how to:
    infoTable = new JTable(data,columnNames);
    infoTable.setSelectionMode(ListSelectionModel.SING LE_SELECTION);

    i wanna make that if use click on row, let's say row no 2, that row no2 get selected but user cant edit it

    i know that there is infoTable.setEnabled(true,false); but when i make that i cant select row ( i just need row selection no editing).

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: JTable selecting single row problem

    You need to override the isCellEditable(...) method of JTable to return false, if you don't want the cells to be editable.
    ContoNick likes this.

  3. #3
    ContoNick is offline Member
    Join Date
    Dec 2011
    Location
    Croatia,Zagreb
    Posts
    24
    Rep Power
    0

    Default Re: JTable selecting single row problem

    something like this work's perfecly for me and my problem :) thanks :)

    Java Code:
    DefaultTableModel model = new DefaultTableModel(data,columnNames) {
    			public boolean isCellEditable(int row, int column) {
    					return false;
    			}
    		};

Similar Threads

  1. JTable don't display single Gridline
    By Kilian in forum AWT / Swing
    Replies: 4
    Last Post: 03-16-2011, 04:15 PM
  2. Replies: 1
    Last Post: 10-02-2008, 07:03 PM
  3. Replies: 1
    Last Post: 10-02-2008, 07:02 PM
  4. Replies: 1
    Last Post: 10-02-2008, 07:01 PM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •