I'm new in Java Swing and I have a strange problem to refresh my JPanel
.
I create a static JPanel
componant in my frame and I call a static method from a FileListenner
to repaint my JPanel
public static void repaintPlan(JPanel f) {
f.paint(f.getGraphics());
f.revalidate(); // or validate
}
I mean, when I detect change in file content, I calculate the new coordinates and I repaint the JPanel
(I create a class exends from JPanel to define
paintComponent()` method)
Everything is working fine when I run the app, and the repaint works when a change data in file; but if I click with my mouse in the Jpanel
, the repaint()
method doesn't work anymore. Can you tell me why after clicking on JPanel
, repainting doesn't work ?
Sorry for my bad english Thanks in advance:)
Edit: Thanks for your repsonses! But even if I use repaint()
method, it's the same problem. I'm trying to understand what happens when I click on JPanel
. Should I use mouse events in Swing to solve the problem?