Reputation: 49
I'm a beginner in Java. My code:
public PlanetSimulator() throws InterruptedException {
JPanel panel = new JPanel();
panel.setBounds(64, 35, 840, 600);
Draw view = new Draw();
panel.add(view);
Drawing in panel Sun and Stars and Black Background.
How can I say Java "Hey you see that panel? Draw there another thing" But I'm saying in to Java not from the PlanetSimulator, but main function.
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
PlanetSimulator frame = new PlanetSimulator();
frame.setVisible(true);
//DrawPlanetOne DrawPlanetOne = new DrawPlanetOne()
//PlanetSimulator.panel.add(DrawPlanetOne)
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
But it doesn't work. Yes I known that I'm amateur. Rysowanie / Draw class http://pastebin.com/RkcTBxrN
Upvotes: 1
Views: 72
Reputation: 80
I assume, this will be a simulation. And if you like to simulate something with 30FPS, it will be hard with a Panel. You could use a library like processing to animate your planets and stuff. It's a lot easier as using a JPane. But you could call the repaint method?
Upvotes: 1