I was wondering if you could help me out with the structure of my program. I'm making a game with Java and I have 2 classes. 1 class is a graphics class that extends JFrame with a paint method:
Graphics Class paint() and calls various objects that use JFrame as a parameter. Inside the class is a subclass that implements MouseListener and Mouse Motion Listener which interacts with paint method.
Canvas Class I was planning to embed the first class into a larger canvas class that would have buttons, panels, and so forth so essentially use the class as a smaller (sub-program) inside a larger program. Is this possible/ am I doing this the right way. Whenever I try to call the graphic class inside the canvas class, the graphic doesn't turn up.
public Canvas(){
graphic = new Graphic(name);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Canvas canvas = new Canvas();
canvas.setDefaultCloseOperation(EXIT_ON_CLOSE);
canvas.setSize(1500, 1500);
canvas.setVisible(true);
}
} Any help/guidance would be appreciated. I just want to mainly to know if I'm thinking about graphic programming correctly.