Jeetesh Nataraj
Jeetesh Nataraj

Reputation: 608

Explanation for the java code?

What does this code mean:

table = new JTable(){
        public boolean isCellEditable(int arg0, int arg1) {
            return true;
        }
    };

Upvotes: 3

Views: 99

Answers (3)

Bohemian
Bohemian

Reputation: 425003

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

Upvotes: 4

Luchian Grigore
Luchian Grigore

Reputation: 258568

Think of it as:

class MyJTable extends JTable
{
    public boolean isCellEditable(int arg0, int arg1) {
        return true;
    }
}
table = new MyJTable;

Upvotes: 2

Piskvor left the building
Piskvor left the building

Reputation: 92752

Whatever arguments you pass to isCellEditable of this instance of JTable, it will always return true. This is not the default behavior in JTable, so you're overriding this behavior of your instance.

(If you meant "why would anyone do that", it should get you a JTable in which every cell is editable)

Upvotes: 0

Related Questions