Java Code Examples for javax.swing.JFrame#setMinimumSize()
The following examples show how to use
javax.swing.JFrame#setMinimumSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: bug8071705.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 2
Source File: SwingSet2.java From beautyeye with Apache License 2.0 | 6 votes |
/** * Create a frame for SwingSet2 to reside in if brought up * as an application. * * @param gc the gc * @return the j frame */ public static JFrame createFrame(GraphicsConfiguration gc) { JFrame frame = new JFrame(gc); if (numSSs == 0) { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } else { WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { numSSs--; swingSets.remove(this); } }; frame.addWindowListener(l); } //由Jack Jiang于2012-09-22加上,防止因JToolBar的大小而影响JFrame的prefereSize使得没法再缩小 frame.setMinimumSize(new Dimension(100,100)); return frame; }
Example 3
Source File: bug8071705.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 4
Source File: GUI.java From Hollow-Knight-SaveManager with GNU General Public License v3.0 | 5 votes |
private JFrame createFrame(String name){ JFrame ret = new JFrame(name); ret.getContentPane().setPreferredSize(new Dimension(0,0)); ret.setMinimumSize(new Dimension(815, 500)); ret.setMaximumSize(new Dimension(1920,1080)); ret.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); return ret; }
Example 5
Source File: bug8071705.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 6
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 7
Source File: bug8071705.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 8
Source File: bug8071705.java From hottub with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 9
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 10
Source File: bug8071705.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 11
Source File: JFrameTest.java From Bytecoder with Apache License 2.0 | 5 votes |
@Test @Ignore public void testEmptyFrame() { final JFrame window = new JFrame(); window.setMinimumSize(new Dimension(800, 600)); window.setVisible(true); }
Example 12
Source File: bug8071705.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 13
Source File: bug8071705.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 14
Source File: bug8071705.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 15
Source File: RESTMain.java From rest-client with Apache License 2.0 | 5 votes |
/** * * @Title: init * @Description: Component Initialization * @param * @return void * @throws */ public static void init() { MenuBarView mbv = new MenuBarView(); JFrame frame = new JFrame(RESTConst.REST_CLIENT_VERSION); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(mbv.getJMenuBar()); frame.getContentPane().add(RESTView.getView()); frame.pack(); frame.setVisible(true); frame.addWindowListener(wa); frame.setIconImage(UIUtil.getImage(RESTConst.LOGO)); frame.setMinimumSize(new Dimension(RESTConst.MAIN_FRAME_WIDTH, RESTConst.MAIN_FRAME_HEIGHT)); UIUtil.setLocation(frame); }
Example 16
Source File: SkinEditorMainGUI.java From megamek with GNU General Public License v2.0 | 4 votes |
/** * Initializes a number of things about this frame. */ private void initializeFrame() { frame = new JFrame(Messages.getString("ClientGUI.title")); //$NON-NLS-1$ frame.setJMenuBar(menuBar); Rectangle virtualBounds = getVirtualBounds(); int x, y, w, h; if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { x = GUIPreferences.getInstance().getWindowPosX(); y = GUIPreferences.getInstance().getWindowPosY(); w = GUIPreferences.getInstance().getWindowSizeWidth(); h = GUIPreferences.getInstance().getWindowSizeHeight(); if ((x < virtualBounds.getMinX()) || ((x + w) > virtualBounds.getMaxX())) { x = 0; } if ((y < virtualBounds.getMinY()) || ((y + h) > virtualBounds.getMaxY())) { y = 0; } if (w > virtualBounds.getWidth()) { w = (int) virtualBounds.getWidth(); } if (h > virtualBounds.getHeight()) { h = (int) virtualBounds.getHeight(); } frame.setLocation(x, y); frame.setSize(w, h); } else { frame.setSize(800, 600); } frame.setMinimumSize(new Dimension(640, 480)); frame.setBackground(SystemColor.menu); frame.setForeground(SystemColor.menuText); List<Image> iconList = new ArrayList<Image>(); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_16X16) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_32X32) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_48X48) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_256X256) .toString())); frame.setIconImages(iconList); mechW = new JDialog(frame, Messages.getString("ClientGUI.MechDisplay"), false); x = GUIPreferences.getInstance().getDisplayPosX(); y = GUIPreferences.getInstance().getDisplayPosY(); h = GUIPreferences.getInstance().getDisplaySizeHeight(); w = GUIPreferences.getInstance().getDisplaySizeWidth(); if ((x + w) > virtualBounds.getWidth()) { x = 0; w = Math.min(w, (int)virtualBounds.getWidth()); } if ((y + h) > virtualBounds.getHeight()) { y = 0; h = Math.min(h, (int)virtualBounds.getHeight()); } mechW.setLocation(x, y); mechW.setSize(w, h); mechW.setResizable(true); unitDisplay = new UnitDisplay(null); mechW.add(unitDisplay); mechW.setVisible(true); unitDisplay.displayEntity(testEntity); }
Example 17
Source File: ClientGUI.java From megamek with GNU General Public License v2.0 | 4 votes |
/** * Initializes a number of things about this frame. */ private void initializeFrame() { frame = new JFrame(Messages.getString("ClientGUI.title")); //$NON-NLS-1$ menuBar.setGame(client.getGame()); frame.setJMenuBar(menuBar); Rectangle virtualBounds = getVirtualBounds(); if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { int x = GUIPreferences.getInstance().getWindowPosX(); int y = GUIPreferences.getInstance().getWindowPosY(); int w = GUIPreferences.getInstance().getWindowSizeWidth(); int h = GUIPreferences.getInstance().getWindowSizeHeight(); if ((x < virtualBounds.getMinX()) || ((x + w) > virtualBounds.getMaxX())) { x = 0; } if ((y < virtualBounds.getMinY()) || ((y + h) > virtualBounds.getMaxY())) { y = 0; } if (w > virtualBounds.getWidth()) { w = (int) virtualBounds.getWidth(); } if (h > virtualBounds.getHeight()) { h = (int) virtualBounds.getHeight(); } frame.setLocation(x, y); frame.setSize(w, h); } else { frame.setSize(800, 600); } frame.setMinimumSize(new Dimension(640,480)); frame.setBackground(SystemColor.menu); frame.setForeground(SystemColor.menuText); List<Image> iconList = new ArrayList<>(); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_16X16).toString() )); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_32X32).toString() )); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_48X48).toString() )); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_256X256).toString() )); frame.setIconImages(iconList); }
Example 18
Source File: Gui.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 4 votes |
public Gui(MessageDigest hashAlgorithm) { /* try { // UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } */ this.hashAlgorithm = hashAlgorithm; isSimple = true; frame = new JFrame("Tectonicus"); topPanel = new JPanel(); topPanel.setLayout( new BoxLayout(topPanel, BoxLayout.Y_AXIS)); infoPanel = createInfoPanel(); simplePanel = createSimplePanel(); advancedPanel = createAdvancedPanel(); advancedPanel.setVisible(false); togglePanel = createTogglePanel(); topPanel.add(infoPanel); topPanel.add(simplePanel); topPanel.add(advancedPanel); topPanel.add(togglePanel); topPanel.setBorder( new EmptyBorder(8, 8, 8, 8) ); frame.getContentPane().add(topPanel); frame.setMinimumSize( new Dimension(400, 10) ); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); internalOnControlModified(); }
Example 19
Source File: Main.java From blog with Apache License 2.0 | 4 votes |
public void createAndShowUI() { BoundedRangeModel progressModel = new DefaultBoundedRangeModel(); BoundedRangeProgress progressAdapter = new BoundedRangeProgress(progressModel); Document resultDocument = new PlainDocument(); ComponentVisibility progressBarVisibility = new ComponentVisibility("enabled", false); progressBarVisibility.setInvisibleDelay(1, TimeUnit.SECONDS); ProgressCancelAction cancelAction = new ProgressCancelAction(); cancelAction.putValue(Action.NAME, "Cancel"); ProgressSimulationAction progressAction = new ProgressSimulationAction(); progressAction.addProgressAware(progressAdapter); progressAction.addProgressAware(cancelAction); progressAction.addPropertyChangeListener(progressBarVisibility); progressAction.putValue(Action.NAME, "Start"); progressAction.setResultDocument(resultDocument); JFrame mainFrame = new JFrame("Progress Object Pattern with Java Swing"); mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); mainFrame.setMinimumSize(new Dimension(600, 120)); JProgressBar progressBar = new JProgressBar(progressModel); progressBar.setVisible(false); progressBar.setStringPainted(true); progressBarVisibility.setComponent(progressBar); JButton startProgressButton = new JButton(progressAction); JButton cancelButton = new JButton(cancelAction); JTextField resultTextField = new JTextField(40); resultTextField.setEditable(false); resultTextField.setDocument(resultDocument); JPanel mainPanel = new JPanel(); mainPanel.add(startProgressButton); mainPanel.add(cancelButton); mainPanel.add(resultTextField); Container contentPane = mainFrame.getContentPane(); contentPane.add(mainPanel); contentPane.add(progressBar, BorderLayout.SOUTH); mainFrame.pack(); mainFrame.setLocationRelativeTo(null); mainFrame.setVisible(true); }