Hi,
I am very new to swing and
java awt. I am trying an application where I have 2 panels in main container. First panel (p1)contains some data and a button , upon click of button, Second panel (p2) has to draw a graph based on the content of first panel.
To draw the graph I am creating another class called secondPanel and passing p2 in the constructor, to get the graphics object of p2 to draw the graph.
The problem I am getting is when I change the data and redo the graph it retains the old graph. As I understand it is because of the graphics object that I am getting from p2.
before passing object p2 to the constructor of SecondPanel, I am calling removeAll() and validate() on p2, however my graphics object is not recreated.
Really appreciate if someone can help me here. Here is the code snippet of SecondPanel.
In the main container here is my code of reloading p2
How can I reload the graphics. while using super.paintComponent(g), I am getting null pointer exception and I don't know whether graphics object obtained by super will fit my requirement.
Thanks in advance!!!.