Before I have to end it all can anyone help me? I am new to Java but not totally new to programming and I work in I.T.

I have an assignment for college (which is now late : - ( where I have to take the classic cannon game by Budd and make it more OOP by subdividing the mass of code in one file into seperate classes that interact and pass messages to each other. I am having problems with the paint method.

Its a simple program that draws a cannon and target as a series of lines. If I include the paint method (and all the code to draw the lines) in the main class (i.e containing the main method) it will draw to the frame. If I remove this code into a subclass and pass all the variables to generate the lines/boxes (i.e x,y coordinates, height, width) it won't redraw. I am at my wits end at this stage. All the code examples I have seen on the web would imply it should work.

Could the problem be that when all in class A it calls the paint method, any change to the variables thus calls the repaint method. When you subdivide these into different classes A and B you ask A to pass to be B all the variables necessary to draw the object but you cannot call repaint as it was never painted?

Here is my code. This is just a simple example of what I am trying to do.

Do I need to draw it first in the main class?

//SimpleDraw.java
import java.awt.*;
import java.awt.event.*;

public class SimpleDraw extends Frame{

public static void main (String argv[]){
SimpleDraw simple = new SimpleDraw();
simple.setVisible(true);
}


public static final int FrameWidth = 600;
public static final int FrameHeigth = 400;
public int x = 450;
public int y = 12;
public int width = 50;
public int height = 20;
protected DrawBox drawBox;
protected Color color;
private int curveLeft=6;
private int curveRight=6;



private SimpleDraw(){
setSize(FrameWidth,FrameHeigth);
setTitle("As Simple As Me");
drawBox = new DrawBox(x, y, width, height, curveLeft, curveRight);
repaint( );
}


}



//DrawBox.java
import java.awt.*;
import java.awt.event.*;


public class DrawBox extends Rectangle{


public int x = 450;
public int y = 12;
public int width = 50;
public int height = 20;
protected Color color;
private int curveLeft=6;
private int curveRight=6;
public static final int FrameHeigth = 400;


public DrawBox(int x, int y, int width, int height, int curveLeft, int curveRight){

color = Color.blue;



}

public int dy(int y){
return FrameHeigth - y;
}


public void paint(Graphics g){
g.setColor(Color.red);
g.fillRoundRect(x, dy(y), width, height,curveLeft,curveRight);
}





}

Thanking you in advance!

Claire