Repaint and paintComponent() in Java
-
04-12-2019 - |
题
I am reading data continuously from a sensor and want to plot chart using that data. I already create that chart, however, system draws that chart for only the first reading, doesn't change the plot dynamically.
I used paintComponent() and I try to update that by using repaint. I have found that though data updates continuously, but the program doesn't execute paintComponent() for more than one time.
any suggestion to solve that problem would be highly appreciated.
解决方案
Try
validate()
or revalidate()
and then,
call repaint()
Hope this will help.
Helpful Link : http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#revalidate()
不隶属于 StackOverflow