Example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment.

Prototype

public static GraphicsEnvironment getLocalGraphicsEnvironment() 

Source Link

Document

Returns the local GraphicsEnvironment .

Usage

From source file:com.game.ui.views.MapPanel.java

public void buildMap(MapInformation Map) throws IOException {
    getMapInformation(Map);/*w w w  .  j  a  va 2 s . com*/
    mapPanel = new JPanel();
    mapPanel.setLayout(new GridLayout(mapRows, mapColumns));
    tile = new JButton[mapRows * mapColumns];
    commandCounter = 1;
    for (int x = 0; x < mapRows; x++) {
        for (int y = 0; y < mapColumns; y++) {
            tile[commandCounter - 1] = new JButton();
            (tile[commandCounter - 1]).setActionCommand("" + commandCounter);
            tile[commandCounter - 1].addActionListener(this);
            mapPanel.add(tile[commandCounter - 1]);
            tileInformation = pathMap.get(commandCounter);
            if (tileInformation != null) {
                mapPathPoints();
                if (tileInformation.isEndTile()) {
                    mapEndPoints();
                }
                if (tileInformation.isStartTile()) {
                    mapStartPoints();
                    numberofPlayers++;
                }
                if (tileInformation.getEnemy() != null) {
                    mapEnemyPoints(tileInformation);
                    numberofEnemys++;
                }
            }
            commandCounter++;
        }
    }
    UIManager.installLookAndFeel("SeaGlass", "com.seaglasslookandfeel.SeaGlassLookAndFeel");

    wrapperPanel.add(mapPanel, BorderLayout.CENTER);
    add(wrapperPanel);
    pack();
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(env.getMaximumWindowBounds());
    setVisible(true);
}

From source file:nz.govt.natlib.ndha.manualdeposit.dialogs.ApplicationProperties.java

private void setupForm(final String settingsPath) {
    this.setTitle("System Properties");
    try {/*from   ww  w. j ava2s  . c  o  m*/
        theFormControl = new FormControl(this, settingsPath);
    } catch (Exception ex) {
        LOG.error("Error loading form parameters", ex);
    }
    // Set fonts
    isSystemChange = true;
    final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final Font[] fonts = env.getAllFonts();
    DefaultListModel model = new DefaultListModel();
    for (int i = 0; i < fonts.length; i++) {
        final Font font = fonts[i];
        model.add(i, font.getName());
    }
    lstFont.setModel(model);

    // Set styles
    model = new DefaultListModel();
    model.addElement("Plain");
    model.addElement("Bold");
    model.addElement("Italic");
    model.addElement("Bold Italic");
    lstStyle.setModel(model);

    // Set sizes
    model = new DefaultListModel();
    model.addElement("8");
    model.addElement("10");
    model.addElement("12");
    model.addElement("14");
    model.addElement("18");
    model.addElement("20");
    model.addElement("22");
    model.addElement("24");
    lstSize.setModel(model);
    txtFontSize.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(final DocumentEvent e) {
            updateFontSize();
        }

        public void removeUpdate(final DocumentEvent e) {
            updateFontSize();
        }

        public void insertUpdate(final DocumentEvent e) {
            updateFontSize();
        }
    });

    model = new DefaultListModel();
    for (String favourite : personalSettings.getFavourites()) {
        model.addElement(favourite);
    }
    lstFavourites.setModel(model);

    model = new DefaultListModel();
    for (PersonalSettings.FileDescriptions descriptions : personalSettings.getFilesToIgnore()) {
        model.addElement(descriptions);
    }
    lstFilesToIgnore.setModel(model);

    final DefaultComboBoxModel cmbModel = new DefaultComboBoxModel();
    for (PersonalSettings.TextPosition position : PersonalSettings.TextPosition.values()) {
        cmbModel.addElement(position);
    }
    cmbTextPosition.setModel(cmbModel);

    chkSortRunning.setSelected(personalSettings.isSortRunningAscending());
    chkSortPending.setSelected(personalSettings.isSortPendingAscending());
    chkSortFailed.setSelected(personalSettings.isSortFailedAscending());
    chkSortDeposited.setSelected(personalSettings.isSortDepositedAscending());
    chkSortComplete.setSelected(personalSettings.isSortCompleteAscending());
    txtNoOfRetries.setText(String.format("%d", personalSettings.getNoOfRetries()));

    isSystemChange = false;
}

From source file:misc.ModalityDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method is invoked from the/*  w  ww . ja v  a 2  s . c om*/
 * event-dispatching thread.
 */
private void createAndShowGUI() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Insets ins = Toolkit.getDefaultToolkit().getScreenInsets(gc);
    int sw = gc.getBounds().width - ins.left - ins.right;
    int sh = gc.getBounds().height - ins.top - ins.bottom;

    // first document

    // frame f1

    f1 = new JFrame("Book 1 (parent frame)");
    f1.setBounds(32, 32, 300, 200);
    f1.addWindowListener(closeWindow);
    // create radio buttons
    rb11 = new JRadioButton("Biography", true);
    rb12 = new JRadioButton("Funny tale", false);
    rb13 = new JRadioButton("Sonnets", false);
    // place radio buttons into a single group
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(rb11);
    bg1.add(rb12);
    bg1.add(rb13);
    JButton b1 = new JButton("OK");
    b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // get label of selected radiobutton
            String title = null;
            if (rb11.isSelected()) {
                title = rb11.getText();
            } else if (rb12.isSelected()) {
                title = rb12.getText();
            } else {
                title = rb13.getText();
            }
            // prepend radio button label to dialogs' titles
            d2.setTitle(title + " (modeless dialog)");
            d3.setTitle(title + " (document-modal dialog)");
            d2.setVisible(true);
        }
    });
    Container cp1 = f1.getContentPane();
    // create three containers to improve layouting
    cp1.setLayout(new GridLayout(1, 3));
    // an empty container
    Container cp11 = new Container();
    // a container to layout components
    Container cp12 = new Container();
    // an empty container
    Container cp13 = new Container();
    // add a button into a separate panel
    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout());
    p1.add(b1);
    // add radio buttons and the OK button one after another into a single column
    cp12.setLayout(new GridLayout(4, 1));
    cp12.add(rb11);
    cp12.add(rb12);
    cp12.add(rb13);
    cp12.add(p1);
    // add three containers
    cp1.add(cp11);
    cp1.add(cp12);
    cp1.add(cp13);

    // dialog d2

    d2 = new JDialog(f1);
    d2.setBounds(132, 132, 300, 200);
    d2.addWindowListener(closeWindow);
    JLabel l2 = new JLabel("Enter your name: ");
    l2.setHorizontalAlignment(SwingConstants.CENTER);
    tf2 = new JTextField(12);
    JButton b2 = new JButton("OK");
    b2.setHorizontalAlignment(SwingConstants.CENTER);
    b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //pass a name into the document modal dialog
            l3.setText("by " + tf2.getText());
            d3.setVisible(true);
        }
    });
    Container cp2 = d2.getContentPane();
    // add label, text field and button one after another into a single column
    cp2.setLayout(new BorderLayout());
    cp2.add(l2, BorderLayout.NORTH);
    cp2.add(tf2, BorderLayout.CENTER);
    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(b2);
    cp2.add(p2, BorderLayout.SOUTH);

    // dialog d3

    d3 = new JDialog(d2, "", Dialog.ModalityType.DOCUMENT_MODAL);
    d3.setBounds(232, 232, 300, 200);
    d3.addWindowListener(closeWindow);
    JTextArea ta3 = new JTextArea();
    l3 = new JLabel();
    l3.setHorizontalAlignment(SwingConstants.RIGHT);
    Container cp3 = d3.getContentPane();
    cp3.setLayout(new BorderLayout());
    cp3.add(new JScrollPane(ta3), BorderLayout.CENTER);
    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p3.add(l3);
    cp3.add(p3, BorderLayout.SOUTH);

    // second document

    // frame f4

    f4 = new JFrame("Book 2 (parent frame)");
    f4.setBounds(sw - 300 - 32, 32, 300, 200);
    f4.addWindowListener(closeWindow);
    // create radio buttons
    rb41 = new JRadioButton("Biography", true);
    rb42 = new JRadioButton("Funny tale", false);
    rb43 = new JRadioButton("Sonnets", false);
    // place radio buttons into a single group
    ButtonGroup bg4 = new ButtonGroup();
    bg4.add(rb41);
    bg4.add(rb42);
    bg4.add(rb43);
    JButton b4 = new JButton("OK");
    b4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // get label of selected radiobutton
            String title = null;
            if (rb41.isSelected()) {
                title = rb41.getText();
            } else if (rb42.isSelected()) {
                title = rb42.getText();
            } else {
                title = rb43.getText();
            }
            // prepend radiobutton label to dialogs' titles
            d5.setTitle(title + " (modeless dialog)");
            d6.setTitle(title + " (document-modal dialog)");
            d5.setVisible(true);
        }
    });
    Container cp4 = f4.getContentPane();
    // create three containers to improve layouting
    cp4.setLayout(new GridLayout(1, 3));
    Container cp41 = new Container();
    Container cp42 = new Container();
    Container cp43 = new Container();
    // add the button into a separate panel
    JPanel p4 = new JPanel();
    p4.setLayout(new FlowLayout());
    p4.add(b4);
    // add radiobuttons and the OK button one after another into a single column
    cp42.setLayout(new GridLayout(4, 1));
    cp42.add(rb41);
    cp42.add(rb42);
    cp42.add(rb43);
    cp42.add(p4);
    //add three containers
    cp4.add(cp41);
    cp4.add(cp42);
    cp4.add(cp43);

    // dialog d5

    d5 = new JDialog(f4);
    d5.setBounds(sw - 400 - 32, 132, 300, 200);
    d5.addWindowListener(closeWindow);
    JLabel l5 = new JLabel("Enter your name: ");
    l5.setHorizontalAlignment(SwingConstants.CENTER);
    tf5 = new JTextField(12);
    tf5.setHorizontalAlignment(SwingConstants.CENTER);
    JButton b5 = new JButton("OK");
    b5.setHorizontalAlignment(SwingConstants.CENTER);
    b5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //pass a name into the document modal dialog
            l6.setText("by " + tf5.getText());
            d6.setVisible(true);
        }
    });
    Container cp5 = d5.getContentPane();
    // add label, text field and button one after another into a single column
    cp5.setLayout(new BorderLayout());
    cp5.add(l5, BorderLayout.NORTH);
    cp5.add(tf5, BorderLayout.CENTER);
    JPanel p5 = new JPanel();
    p5.setLayout(new FlowLayout());
    p5.add(b5);
    cp5.add(p5, BorderLayout.SOUTH);

    // dialog d6

    d6 = new JDialog(d5, "", Dialog.ModalityType.DOCUMENT_MODAL);
    d6.setBounds(sw - 500 - 32, 232, 300, 200);
    d6.addWindowListener(closeWindow);
    JTextArea ta6 = new JTextArea();
    l6 = new JLabel();
    l6.setHorizontalAlignment(SwingConstants.RIGHT);
    Container cp6 = d6.getContentPane();
    cp6.setLayout(new BorderLayout());
    cp6.add(new JScrollPane(ta6), BorderLayout.CENTER);
    JPanel p6 = new JPanel();
    p6.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p6.add(l6);
    cp6.add(p6, BorderLayout.SOUTH);

    // third document

    // frame f7

    f7 = new JFrame("Classics (excluded frame)");
    f7.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
    f7.setBounds(32, sh - 200 - 32, 300, 200);
    f7.addWindowListener(closeWindow);
    JLabel l7 = new JLabel("Famous writers: ");
    l7.setHorizontalAlignment(SwingConstants.CENTER);
    // create radio buttons
    rb71 = new JRadioButton("Burns", true);
    rb72 = new JRadioButton("Dickens", false);
    rb73 = new JRadioButton("Twain", false);
    // place radio buttons into a single group
    ButtonGroup bg7 = new ButtonGroup();
    bg7.add(rb71);
    bg7.add(rb72);
    bg7.add(rb73);
    Container cp7 = f7.getContentPane();
    // create three containers to improve layouting
    cp7.setLayout(new GridLayout(1, 3));
    Container cp71 = new Container();
    Container cp72 = new Container();
    Container cp73 = new Container();
    // add the label into a separate panel
    JPanel p7 = new JPanel();
    p7.setLayout(new FlowLayout());
    p7.add(l7);
    // add a label and radio buttons one after another into a single column
    cp72.setLayout(new GridLayout(4, 1));
    cp72.add(p7);
    cp72.add(rb71);
    cp72.add(rb72);
    cp72.add(rb73);
    // add three containers
    cp7.add(cp71);
    cp7.add(cp72);
    cp7.add(cp73);

    // fourth document

    // frame f8

    f8 = new JFrame("Feedback (parent frame)");
    f8.setBounds(sw - 300 - 32, sh - 200 - 32, 300, 200);
    f8.addWindowListener(closeWindow);
    JButton b8 = new JButton("Rate yourself");
    b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showConfirmDialog(null, "I really like my book", "Question (application-modal dialog)",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        }
    });
    Container cp8 = f8.getContentPane();
    cp8.setLayout(new FlowLayout(FlowLayout.CENTER, 8, 8));
    cp8.add(b8);
}

From source file:de.bamamoto.mactools.png2icns.Scaler.java

public static BufferedImage resize(BufferedImage source, int width, int height) {

    double xScale = ((double) width) / (double) source.getWidth();
    double yScale = ((double) height) / (double) source.getHeight();
    BufferedImage result = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
            .getDefaultConfiguration()//w  ww  . j  a v a  2s .  c  o m
            .createCompatibleImage(width, height, source.getColorModel().getTransparency());
    Graphics2D newImage = null;
    try {
        newImage = result.createGraphics();
        newImage.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        newImage.drawRenderedImage(source, AffineTransform.getScaleInstance(xScale, yScale));
    } finally {
        if (newImage != null) {
            newImage.dispose();
        }
    }
    return result;
}

From source file:org.zanata.util.TestEventForScreenshotListener.java

private Rectangle getScreenRectangle() {
    // http://stackoverflow.com/a/13380999/14379
    Rectangle2D result = new Rectangle2D.Double();
    GraphicsEnvironment localGE = GraphicsEnvironment.getLocalGraphicsEnvironment();
    for (GraphicsDevice gd : localGE.getScreenDevices()) {
        for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()) {
            Rectangle2D.union(result, graphicsConfiguration.getBounds(), result);
        }/*from ww  w  . j  a v a2 s. c  o  m*/
    }
    return new Rectangle((int) result.getWidth(), (int) result.getHeight());
}

From source file:org.pentaho.reporting.libraries.designtime.swing.LibSwingUtil.java

public static boolean safeRestoreWindow(final Window frame, final Rectangle bounds) {
    final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
        final GraphicsDevice device = devices[i];
        final Rectangle rectangle = device.getDefaultConfiguration().getBounds();
        if (rectangle.contains(bounds) || rectangle.equals(bounds)) {
            logger.info("Found a usable screen-configuration: Restoring frame to " + bounds);
            frame.setBounds(bounds);//w ww  .j av a  2  s  .  c o m
            return true;
        }
    }
    return false;
}

From source file:net.sf.maltcms.chromaui.charts.ChartCustomizer.java

public static ChartPanel createChartPanel(JFreeChart chart, int width, int height, boolean useBuffer) {
    Dimension maxSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize();
    ContextAwareChartPanel cacp = new ContextAwareChartPanel(chart, width, height, 50, 50, maxSize.width,
            maxSize.height, useBuffer, true, true, true, true, true, true);
    cacp.setDoubleBuffered(true);// w  w  w  .jav a 2 s .c om
    return cacp;
}

From source file:gate.Main.java

/** Run the user interface. */
protected static void runGui() throws GateException {

    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

    // initialise the library and load user CREOLE directories
    try {/*w w w . java2 s  . c om*/
        Gate.init();
    } catch (Throwable t) {
        log.error("Problem while initialising GATE", t);
        int selection = JOptionPane.showOptionDialog(null,
                "Error during initialisation:\n" + t.toString() + "\nDo you still want to start GATE?", "GATE",
                JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null,
                new String[] { "Cancel", "Start anyway" }, "Cancel");
        if (selection != 1) {
            System.exit(1);
        }
    }

    //create the main frame, show it
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
                    .getDefaultScreenDevice().getDefaultConfiguration();

            //this needs to run before any GUI component is constructed.
            applyUserPreferences();

            //all the defaults tables have been updated; build the GUI
            frame = MainFrame.getInstance(gc);
            if (DEBUG)
                Out.prln("constructing GUI");

            // run the GUI
            frame.setTitleChangable(true);
            frame.setTitle(name + " " + version + " build " + build);

            // Set title from Java properties
            String title = System.getProperty(GateConstants.TITLE_JAVA_PROPERTY_NAME);
            if (title != null) {
                frame.setTitle(title);
            } // if
            frame.setTitleChangable(false);

            // Set icon from Java properties
            // iconName could be absolute or "gate:/img/..."
            String iconName = System.getProperty(GateConstants.APP_ICON_JAVA_PROPERTY_NAME);
            if (iconName != null) {
                try {
                    frame.setIconImage(Toolkit.getDefaultToolkit().getImage(new URL(iconName)));
                } catch (MalformedURLException mue) {
                    log.warn("Could not load application icon.", mue);
                }
            } // if

            // Validate frames that have preset sizes
            frame.validate();

            // Center the window
            Rectangle screenBounds = gc.getBounds();
            Dimension screenSize = screenBounds.getSize();
            Dimension frameSize = frame.getSize();
            if (frameSize.height > screenSize.height) {
                frameSize.height = screenSize.height;
            }
            if (frameSize.width > screenSize.width) {
                frameSize.width = screenSize.width;
            }
            frame.setLocation((screenSize.width - frameSize.width) / 2,
                    (screenSize.height - frameSize.height) / 2);

            frame.setVisible(true);

            //load session if required and available;
            //do everything from a new thread.
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    try {
                        File sessionFile = Gate.getUserSessionFile();
                        if (sessionFile.exists()) {
                            MainFrame.lockGUI("Loading saved session...");
                            PersistenceManager.loadObjectFromFile(sessionFile);
                        }
                    } catch (Exception e) {
                        log.warn("Failed to load session data", e);
                    } finally {
                        MainFrame.unlockGUI();
                    }
                }
            };
            Thread thread = new Thread(Thread.currentThread().getThreadGroup(), runnable, "Session loader");
            thread.setPriority(Thread.MIN_PRIORITY);
            thread.start();
        }
    });
    registerCreoleUrls();
}

From source file:com.game.ui.views.MapEditor.java

public void generateGUI() throws IOException {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    //        setResizable(false);
    JMenuBar menubar = new JMenuBar();
    ImageIcon icon = null;/* w ww .j  a v  a 2 s.c o  m*/
    try {
        icon = GameUtils.shrinkImage("save.png", 20, 20);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JMenu file = new JMenu("File");
    JMenuItem save = new JMenuItem("Save", icon);
    save.setToolTipText("Save Map Information");
    save.setActionCommand("Save Map");
    save.addActionListener(this);
    file.add(save);
    menubar.add(file);
    setJMenuBar(menubar);
    JPanel topPanel = new JPanel();
    topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    topPanel.setLayout(new GridBagLayout());
    JLabel headerLbl = new JLabel("Legend : ");
    headerLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    JLabel lbl1 = new JLabel();
    lbl1.setPreferredSize(new Dimension(50, 20));
    lbl1.setBackground(Configuration.pathColor);
    lbl1.setOpaque(true);
    JLabel lbl2 = new JLabel("- Represents the path.");
    JLabel lbl3 = new JLabel();
    lbl3.setPreferredSize(new Dimension(50, 20));
    lbl3.setBackground(Configuration.enemyColor);
    lbl3.setOpaque(true);
    JLabel lbl4 = new JLabel("- Represents the path with monsters");
    JLabel lbl5 = new JLabel();
    lbl5.setPreferredSize(new Dimension(50, 20));
    lbl5.setBackground(Configuration.startPointColor);
    lbl5.setOpaque(true);
    JLabel lbl6 = new JLabel("- Represents the starting point in the path");
    JLabel lbl7 = new JLabel();
    lbl7.setBackground(Configuration.endPointColor);
    lbl7.setOpaque(true);
    lbl7.setPreferredSize(new Dimension(50, 20));
    JLabel lbl8 = new JLabel("- Ending point in the path");
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 2;
    topPanel.add(headerLbl, c);
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.ipadx = 5;
    c.ipady = 5;
    topPanel.add(lbl1, c);
    c.gridx = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    topPanel.add(lbl2, c);
    c.gridx = 0;
    c.gridy = 2;
    topPanel.add(lbl3, c);
    c.gridx = 1;
    topPanel.add(lbl4, c);
    c.gridx = 0;
    c.gridy = 3;
    topPanel.add(lbl5, c);
    c.gridx = 1;
    topPanel.add(lbl6, c);
    c.gridx = 0;
    c.gridy = 4;
    topPanel.add(lbl7, c);
    c.gridx = 1;
    topPanel.add(lbl8, c);
    add(topPanel, BorderLayout.NORTH);
    bottomPanel = new JPanel();
    add(bottomPanel, BorderLayout.CENTER);
    bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    //        bottomPanel.add(new JButton("kaushik"));
    pack();
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(env.getMaximumWindowBounds());
    setVisible(true);
    callDialogForUsersInput();
}

From source file:com.grillecube.editor.ModelEditor.java

private JSONObject createDefaultJSON() {
    JSONObject json = new JSONObject();

    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int width = gd.getDisplayMode().getWidth();

    width = width / 2;//from   w  w w  . jav a2 s  . c  o  m
    json.put(ModelEditor.Config.MODEL_WINDOW_WIDTH, width);
    json.put(ModelEditor.Config.MODEL_WINDOW_HEIGHT, width / 1.6f);
    json.put(ModelEditor.Config.VSYNC, 1);
    json.put(ModelEditor.Config.SOUND, 1);

    return (json);
}