Originally Posted by
bglueck
thank you so much copeg. ill add that. will I need to take all the drawOval calls out of the various constructors and put them in that override or can they remain there, just slightly altered? if the latter is true, will I have to incorporate some sort of JPanel code to the fillOval? what will be the new call if so?
My advice would be to think "object oriented programming". Each object has its purpose, and to separate each object based upon that purpose. For example, you have defined classes (World, Meteor, etc..) and could then have classes which define how these are drawn (JPanel(s), etc..). As an pseudo-example
public class MyPanel extends JPanel{
private Meteor meteor;
private World world;
public MyPanel(Meteor m, World w){
meteor = m;
world = w;
}
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawOval(..get meteor values....);
....etc....
}
}
You could also place draw methods in your classes, which you can pass a Graphics object to and can be called from the paintComponent...many ways to go about it.