for a programming project i haft to be able to draw two rectangles and show only the two most recent ones (i also haft to detect if they over lap and show it but i haven't made an attempt at this yet so if you want to go into it i would be great full , however it isn't necessary for you to do so). so far my code works off and on and with drawing one rectangle but not two i also haven't started with drawing the most recent, only two then a repaint. as of now my code is really bloated if there is a more efficient way if doing this (ie. arrays for holding the coordinates ( i havent had time to fiddle with them)) i would be great full if you showed me. for this project i used net beans 6.8. thanks for your help, i am new to this form so if i posted this in the wrong place please let me know

Please use code tags when you posting next time. Unformated codes are really hard to read. If you don't know how to added code tags, check on my signature. You can find a link to relevant page.

04-12-2010, 05:06 AM

Fubarable

You have problems here. Please see the // !! comments:

Code:

public void paintComponent(rectangle i) {

// !! do not use getGraphics to get a workable Graphics object. The object obtained won't persist.
// !! so this entire method needs to go and be replaced by the paintComponent method below
Graphics gDisplay = jPDisplay.getGraphics();