简体   繁体   中英

How to click on JTable itself?

I want to click on JTable which is not enabled to make it enabled but JTable don't recognize my click or even JList it don't recognize my click too .. so how to click on it ?

and this is my code :

table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            table.setEnabled(true);
        }
    });

Works fine for me.

Maybe the problem is that the table doesn't get focus when you enable it. Try something like:

table.setEnabled(true);
table.requestFocusInWindow();

Although I might suggest a better UI would be to add a "Enable Table" checkbox to the form. Since this is no visual cue that a table is enabled/disabled. Also how does the user know to click on the table to enable it? The checkbox is more self documenting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM