I have a main JFrame that is interactive, i.e. user sets different options. After pressing a "run" button config file is create from user preferences and it is passed to next part of the program. Some calculations are done and the results are written to a file. Third part of the program reads the results file and summarizing them.
Then child JFrame is opened consisting of JTabbedPane with several JPanels. Each of the JPanels shows different JTables with the relevant info. The child JFrame has DISPOSE_ON_CLOSE method otherwise both JFrames are killed.
So t开发者_运维知识库he problems is that if user change some options, run the program again, the new child JFrame is not actually new - it shows only the info from first run. I've tried:
invalidate()
revalidate()
repaint()
Nothing helps. I don't know where the problem is. I'm pretty sure that after changing options the new results file is read because it prints in the console.
May be other important thing is that the tables are created first and child JFrame is call latest.
Probably because somewhere in your code you have:
table = new JTable(...);
This does not add the table to the GUI. Instead of creating a new table you should refresh the data in the existing table by doing:
TableModel model = ....
table.setModel( model );
This will cause the data to be repainted automatically. There is no need for invalidate(), revalidate() or repaint().
精彩评论