Example usage for javax.swing JFrame setMaximizedBounds

List of usage examples for javax.swing JFrame setMaximizedBounds

Introduction

In this page you can find the example usage for javax.swing JFrame setMaximizedBounds.

Prototype

public void setMaximizedBounds(Rectangle bounds) 

Source Link

Document

Sets the maximized bounds for this frame.

Usage

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

public static void main(String args[]) {

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                Color SELECTED_COLOR = new Color(184, 204, 217);
                Color BASE_COLOR = new Color(220, 231, 243, 50);
                Color ALT_COLOR = new Color(220, 231, 243, 115);

                //                    Insets MENU_INSETS = new Insets(1,12,2,5);//default values
                //                    Font MENU_FONT = new Font("SansSerif ", Font.PLAIN, 12);//default values

                //                    UIManager.put("nimbusBase", BASE_COLOR);
                UIManager.put("nimbusSelection", SELECTED_COLOR);
                UIManager.put("nimbusSelectionBackground", SELECTED_COLOR);
                UIManager.put("Menu[Enabled+Selected].backgroundPainter", SELECTED_COLOR);

                //override defaults
                for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    if (info.getName().equals("Nimbus")) {
                        UIManager.setLookAndFeel(info.getClassName());
                        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
                        defaults.put("Table.gridColor", Color.lightGray);
                        defaults.put("Table.disabled", false);
                        defaults.put("Table.showGrid", true);
                        defaults.put("Table.intercellSpacing", new Dimension(1, 1));
                        break;
                    }/* w w w . j av a  2s  .c  o m*/
                }

                //                    UIManager.put("TitledBorder.position", TitledBorder.TOP);

                //                    UIManager.put("Table.showGrid", true);
                //                    UIManager.put("Table.gridColor", Color.RED);
                //                    UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
            } catch (UnsupportedLookAndFeelException ulafe) {
                //                    logger.fatal("Substance failed to set", ulafe);
            } catch (Exception ex) {
                //                    logger.fatal(ex.getMessage(), ex);
            }

            JFrame frame = new Jmetrik();

            //            set window to maximum size but account for taskbar
            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Rectangle rect = env.getMaximumWindowBounds();
            int width = Double.valueOf(rect.getWidth() - 1.0).intValue();
            int height = Double.valueOf(rect.getHeight() - 1.0).intValue();
            frame.setMaximizedBounds(new Rectangle(0, 0, width, height));
            frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            frame.pack();
            //            frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            frame.setVisible(true);

            //check for updates to jmetrik
            ((Jmetrik) frame).checkForUpdates();
        }
    });

}