Here you can find the source of openWindow(final JPanel panel)
Parameter | Description |
---|---|
panel | JPanel to display, its name and dimension will be used when formatting the window. |
public static void openWindow(final JPanel panel)
//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); } }