Xihar
Xihar

Reputation: 121

How to disable JTable mouse click?

I have a JTable and after click any row a JDialog open.I want to do until a JDialog not close then another JDialog will not open or disable mouse click on the rows. Implemented source code are following:

table = new JTable();
table.addMouseListener(new MouseAdapter() {
@SuppressWarnings("unchecked")
@Override
public void mouseClicked(MouseEvent arg0) {                 
Update update=new Update();     
try{                    
 int row=table.getSelectedRow();
 String getvalue= (table.getModel().getValueAt(row, 0).toString());
 update.setVisible(true);
 //here I want to disable mouseclick listener
 table.setEnabled(false);   //It does not work
   }
 });

Note: I want to update my data using JDialog.

Need to help on this. Thanks in advance.

Upvotes: 0

Views: 177

Answers (1)

DevilsHnd - 退した
DevilsHnd - 退した

Reputation: 9192

:D The JDialog has a property named modal. Set it to: true. Something like this

jDialog1.setModal(true);

You should also set the alwaysOnTop property to true as well

That should do it.

Upvotes: 1

Related Questions