I am working on a Java plug-in that works fine except for a repainting (refreshing) problem. The plug-in pulls in some information from external source via a button click and populates correctly the first time through. However, when I try to refresh the data, the Swing components won't repaint. I've tried a number of different ways of coding this, but with no luck. Below is the class in question. There is another class that I have not included (FillTable) that simply provides the row/column logic for the data results set. Please see my code below:
Any insights as to why the GUI won't refresh would be appreciated. Thank you.
I see that you are creating new Swing components every time the button is clicked. Presumably (I haven't looked too closely) you're putting the data into them, but the original versions of the components are still the ones which are displayed. I don't think that creating new components on every button click is a good idea, even if you did remove the old ones and add the new ones. It makes much more sense to just update the components which are already there.
Joined: Jul 29, 2011
Thanks for your response, that makes perfect sense. However, perhaps due to my being a relative novice in Swing, I'm not sure how to effect this change. Can you suggest how to modify this syntax if I created the new JTable outside of the createComponent() method? The current code is below:
The myModel method returns type FillTable...the other class not shown that extends AbstractTableModel. If I simply use , compilation fails with the error "Cannot convert FillTable to JTable". Any ideas what the syntax should be?