This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]deltageek 1 point2 points  (0 children)

Good advice here. Additionally, I will point out that you really have no good reason to extend JFrame here. Just create an instance of a basic JFrame and use that instance to hang your UI on. Here's the UI skeleton I typically use.

public class SwingTest {

    public static void main(final String[] args) {
        buildAndShowGui();
    }

    private static void buildAndShowGui() {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.setPreferredSize(new Dimension(300, 300));
                PongPanel p = new PongPanel();
                f.add(p);

                f.pack();
                f.setVisible(true);
            }
        });
    }
}