Created
August 9, 2013 13:03
-
-
Save zzorn/6193462 to your computer and use it in GitHub Desktop.
SimpleFrame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.*; | |
| import java.awt.*; | |
| /** | |
| * A Swing JFrame with sensible default settings. | |
| */ | |
| public class SimpleFrame extends JFrame { | |
| private static final int DEFAULT_WIDTH = 800; | |
| private static final int DEFAULT_HEIGHT = 600; | |
| public SimpleFrame() { | |
| this("", null); | |
| } | |
| public SimpleFrame(String title) { | |
| this(title, null); | |
| } | |
| public SimpleFrame(String title, JComponent content) { | |
| this(title, content, DEFAULT_WIDTH, DEFAULT_HEIGHT); | |
| } | |
| public SimpleFrame(String title, JComponent content, int initialWidth, int initialHeight) { | |
| setTitle(title); | |
| if (content != null) setContentPane(content); | |
| setPreferredSize(new Dimension(initialWidth, initialHeight)); | |
| setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |
| pack(); | |
| setVisible(true); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment