开发者

Explanation for the java code?

What does this code mean:

table = new开发者_如何学编程 JTable(){
        public boolean isCellEditable(int arg0, int arg1) {
            return true;
        }
    };


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


Think of it as:

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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜