MKS
MKS

Reputation: 786

Repaint and paintComponent() in Java

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.

Upvotes: 1

Views: 528

Answers (1)

TeaCupApp
TeaCupApp

Reputation: 11452

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()

Upvotes: 2

Related Questions