Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Disabling MouseEvents in JTable  RSS feed

 
rajendracv chaturvyas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can any one suggest, how to disable the mouse-events in JTable?
I've embedded JTable in JScrollPane which inturn has been added to a JFrame.
The user should not be able to either select or edit any of the cell in JTable. but, should only be able to view records using scrollbar.
Thanx in Advance
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajendracv,
Allow me to suggest, that rather than disabling mouse events, you use the following "JTable" methods to disable cell, column or row selection:

Disabling cell editing can be achieved by overriding the "isCellEditable()" method in the "javax.swing.table.TableModel" interface.
But if you really want to disable mouse events, then I suggest (although I haven't tried it myself) that you remove the mouse listeners associated with the "JTable". From the javadocs, it looks like a combination of methods "getMouseListeners()" and "removeMouseListener()" will accomplish this. The javadocs I am referring to are located here:
http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/JTable.html
Hope this helps you.
Good Luck,
Avi.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!