Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explanation for the java code?

Tags:

java

swing

jtable

What does this code mean:

table = new JTable(){
        public boolean isCellEditable(int arg0, int arg1) {
            return true;
        }
    };
like image 657
Jeetesh Nataraj Avatar asked Apr 18 '26 01:04

Jeetesh Nataraj


2 Answers

It's an anonymous class, which in this case has provided an implementation for JTable's isCellEditable method that always returns true.

like image 82
Bohemian Avatar answered Apr 20 '26 16:04

Bohemian


Think of it as:

class MyJTable extends JTable
{
    public boolean isCellEditable(int arg0, int arg1) {
        return true;
    }
}
table = new MyJTable;
like image 26
Luchian Grigore Avatar answered Apr 20 '26 15:04

Luchian Grigore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!