what im trying to do is after box1 and box 2 intersect i want to remove all boxes and remove Graphics2D so that i can add a contentpane to the program,calling certain buttons and labels,how would i go about doing or is there a simpler way then what im thinking about?
________
public class BoxIntersection extends JApplet implements Runnable, KeyListener
{

public void init()
{
getContentPane().setLayout(null);
setSize(DISPLAY_WIDTH,DISPLAY_HEIGHT);
setIgnoreRepaint(false);
addKeyListener(this);
//setBackground(Color.CYAN);

backBuffer = new BufferedImage(DISPLAY_WIDTH,DISPLAY_HEIGHT,BufferedImage.TYPE_INT_RGB);
bbGraphics = (Graphics2D) backBuffer.getGraphics();

//create six boxes...
box1 = new Box(DISPLAY_WIDTH/2 - 50,DISPLAY_HEIGHT/2 - 25,100,50);
box2 = new Box(100,100,50,50);
box3 = new Box(0,0,400,5);
box4 = new Box(395,0,5,400);
box5 = new Box(0,0,5,400);
box6 = new Box(0,395,400,5);
}
public void start()
{
loop = new Thread(this);
loop.start();
}

public void stop()
{
loop = null;
}

public void run()
{
long startTime,waitTime,elapsedTime;
//1000/25 FPS = 40ms delay
int delayTime = 1000/25;

Thread thisThread = Thread.currentThread();
while(loop == thisThread)
{
startTime = System.currentTimeMillis();

//render to back buffer now
render(bbGraphics);
//render back buffer image to screen
Graphics g = getGraphics();
g.drawImage(backBuffer, 0, 0,null);
g.dispose();

//handle frame rate
elapsedTime = System.currentTimeMillis() - startTime;
waitTime = Math.max(delayTime - elapsedTime, 5);

try
{
Thread.sleep(waitTime);
}
catch(InterruptedException e)
{
}
}
}

public void render(Graphics g)
{
g.clearRect(0, 0,DISPLAY_WIDTH,DISPLAY_HEIGHT);
if(box1.intersects(box2)) // change the color to white...
{
g.setColor(Color.white);

}
else
g.setColor(Color.green);
box1.render(g);
box2.render(g);
box3.render(g);
box4.render(g);
box5.render(g);
box6.render(g);

______
and below i have key movements that i didnt include in this post