I am creating a graph plotter that plots (draws) datapoints & lines based on periodically updating data points.
I am using a JPanel inside a JFrame as the drawing canvas.
The JPanel contains the line axis & other info (scales etc) as background. It also contains the updating data points as the content.
I would like to update the content of the JFrame periodically, after the new data is fetched. The data points fetching part is complete & works fine.
This is my code: http://pastebin.com/SAEjNT1R , http://pastebin.com/WvPTyEfR (The panel class).
Main:
Panel object class:
This the the OraclePinger package (not really required, in case u wanna run) : At pastebin Wdmd3q1t (Connector class), MycAgyu3 (Target class)
Originally by Oracle - modified by me : docs.oracle.com/javase/1.4.2/docs/guide/nio/example/Ping.java
I am just confused with the JPanel drawing part. I would like to be able to draw the background once, then periodically refresh/clear & redraw the contents.
---Say if it's not possible to separate the background & content while refreshing.. that we only can clear all Components in the panel. Can I at least make a call to something like panel.clearAllComponents(); panel.draw(TheBackGround+Content) (repeatedly) from the Main
How can I solve this ?
Thanks