hello all I am try to display the graphics elements like line with the button component and I choose to display that in Panel using paintComponent But It is display that two time and It is not working properly.
could any one tell me what to do in that case and there is any mecanism to get the graphics object instead of using paintcomponent() fuction because i think that the problem is occuring with that function.
Thanks in advance
Joined: Jan 14, 2004
You can use the JComponent method getGraphics to get a reference to the graphics context. What you draw with it will not survive past the next system–triggered repainting episode. For persistence, it is recommended that you do all drawing from within the paintComponent method for JComponents.
You mentioned Panel which is an AWT component. For AWT components you use the paint method. It is recommended that we not mix Swing and AWT components.