Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Disable editing in JTable

843806Oct 3 2008 — edited Oct 5 2008
Hello,
While building an application i found myself needed to make a doubleclick event.
This is working however, not 100%.
this is becouse the defoult doubleclick action (editing the table) isn't set off.

i looked over the internet but found nothing that helped
yes i even tried:
import javax.swing.table.DefaultTableModel;
class MyTableModel extends DefaultTableModel {
// Insert the instantiator methods I use here

public boolean isCellEditable(int row, int column) {
return false; // Super returns true.
}
}
but it doesn't work.

any and all help would be appriciated.

thanx in advance,
reefclaw

p.s. for those that are interested in my doubleclick function:
TA_Results.addMouseListener(new MouseAdapter()
 {
     public void mouseClicked(MouseEvent e)
     {
//         if (e.getClickCount() == 2)
  //       {
          if(clickedCount == 0)
          {
              Date now = new Date();
              startTijd = now.getTime();
          }
          if(clickedCount == 1)
          {
              Date now = new Date();
              eindTijd = now.getTime();
          }

          clickedCount ++;
          if(clickedCount == 2 )
          {
              clickedCount = 0;
              if(startTijd - eindTijd < 250)
              {
                  JTable target = (JTable) e.getSource();
                  int row = target.getSelectedRow();
                  int column = target.getSelectedColumn();
                  bekijken();
              }
          }

  }
     //}
  });
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 2 2008
Added on Oct 3 2008
9 comments
1,057 views