Java JComponent Size showGUI(final JComponent newContentPane, final String windowTitle, final Dimension size)

Here you can find the source of showGUI(final JComponent newContentPane, final String windowTitle, final Dimension size)

Description

show GUI

License

Open Source License

Declaration

private static JFrame showGUI(final JComponent newContentPane, final String windowTitle, final Dimension size) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Dimension;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class Main {
    private static JFrame showGUI(final JComponent newContentPane, final String windowTitle, final Dimension size) {
        // Create and set up the window.
        final JFrame frame = new JFrame(windowTitle);

        // Create and set up the content pane.
        newContentPane.setOpaque(true); // content panes must be opaque
        frame.setContentPane(newContentPane);

        // Display the window.
        if (size == null) {
            frame.pack();//from  w  w  w .ja  va  2  s  .  com
        } else {
            frame.setSize(size);
        }
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

        return frame;
    }
}

Related

  1. setSMPSizes(JComponent comp, Dimension d)
  2. setUnlimitedSize(JComponent component)
  3. setZeroMinimumSize(Component component)
  4. show(final JComponent component, final String windowTitle, final Dimension size)
  5. showComponent(JComponent component, Dimension size)
  6. showStaticPage(final URI uri, final Dimension size, final Point location)
  7. sizeUniformly(JComponent... components)
  8. springSum(int minimumSize, Spring... spr)