You never add physics
to the JFrame
Main physics = new Main();
JFrame frame = new JFrame("Physics!");
frame.add(physics);
Side Note
When painting on
JPanel
overridegetPreferredSize()
so the panel has a preferred size, then you can justpack()
the frame, as you should be doing, instead of setting it's size@Override public Dimension getPreferredSize() { return new Dimension(500, 500); } ... frame.pack(); // frame.setSize(500, 500);
Also,
paintComponent
should beprotected
notpublic
Also see Initial Threads for running Swing apps on the Event Dispatch Thread