Redrawing graphics in Java?

It's super. PaintComponent(g); not super. PaintComponents(g); // note the s at the edn Big difference between the two!

The first one tells your JPanel to do all the housekeeping functions normally performed by the paintComponent method, including repainting the background (key for your project). The second, the one your calling doesn't do any of the above functionality. So my advice is to get rid of the trailing s in your super call.

This worked, thanks! – Squeazer Mar 13 at 12:27 You're welcome -- thanks for the feedback! – Hovercraft Full Of Eels Mar 13 at 12:34.

You can use the following methods from JComponent: ( download.oracle.com/javase/6/docs/api/ja... ) void repaint(long tm, int x, int y, int width, int height) Adds the specified region to the dirty region list if the component is showing. Void repaint(Rectangle r) Adds the specified region to the dirty region list if the component is showing. You can call those before redraw().

You could use repaint() method to do tis. If you use the paintComponent() on the panel. You should IMHO take care of the painting in the whole panel.

There is no code in your example which takes care about deleting the old painted rectangles. What I recommend is creating an own Component for your rectangles. (You could extend from Component) then you can override the paintComponent method of these classes as you did in your panel.

Because the Panel should act as a container component. Not as drawing the rectangles itsself. Know add instances of these components to a normal JPanel.

This should then update as expected.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions