Java Window openWindow(final JPanel panel)

Here you can find the source of openWindow(final JPanel panel)

Description

Open a new window displaying a JPanel.

License

Open Source License

Parameter

Parameter Description
panel JPanel to display, its name and dimension will be used when formatting the window.

Declaration

public static void openWindow(final JPanel panel) 

Method Source Code


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

import javax.swing.*;
import java.awt.*;

public class Main {
    /**//  w  w  w  . ja  va  2  s.c  o  m
     * Open a new window displaying a JPanel.
     *
     * @param panel JPanel to display, its name and dimension will
     *              be used when formatting the window.
     */
    public static void openWindow(final JPanel panel) {
        final javax.swing.JFrame jf = new javax.swing.JFrame(panel.getName());
        jf.setSize(panel.getWidth(), panel.getHeight());
        jf.add(panel, BorderLayout.CENTER);
        jf.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent e) {
                jf.dispose();
            }
        });
        jf.setVisible(true);
    }
}

Related

  1. growIfNecessary(Window window)
  2. hideWaitPane(Window win, Timer timer)
  3. installPrefsHandler(final Preferences prefs, final String name, Window window)
  4. isResizable(Window window)
  5. modifyDimensions(Window window)
  6. putWindowNormalBounds(Window window, Rectangle bounds)
  7. removeWindow(Window w)
  8. repaintMnemonicsInWindow(Window w)
  9. setWindowAlpha(Window w, int value)