網(wǎng)上看到Jtable中revalidate的說法
Posted on 2009-05-02 01:18 沙漠中的魚 閱讀(584) 評(píng)論(0) 編輯 收藏 所屬分類: Java問題:在找資料的時(shí)候看見JTabel用了setModel方法后會(huì)加上一個(gè)revalidate方法,
可我刪了這個(gè)方法并沒見有什么不同,請(qǐng)指點(diǎn)!
回答一:如果在application上有哪個(gè)component由于事件的觸發(fā)而發(fā)生變化(比如,形狀)的話,這個(gè)方法就是用來更新當(dāng)前程序的界面用的,就相當(dāng)于重畫一下界面
回答二:The original author comments, very clear:
I added a revalidate to JTable in the case that the table structure
changes (columns/rows added/removed). This is necessary, since such an
operation changes the size parameters of the JTable. It makes JTable
behave more nicely in JScrollPane in an app I have here.