Java JFrame wrapPanelInFrame(JFrame frame, JPanel panel, String caption, int width, int height)

Here you can find the source of wrapPanelInFrame(JFrame frame, JPanel panel, String caption, int width, int height)

Description

wrap Panel In Frame

License

Open Source License

Declaration

public static JFrame wrapPanelInFrame(JFrame frame, JPanel panel, String caption, int width, int height) 

Method Source Code


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

import javax.swing.*;

public class Main {
    /** For your main window, you'll want to set this: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
     * because we don't do that here.  This method also sets the frame visible.
     *//*  w  w  w  .  j a va 2s  .  c  o  m*/
    public static JFrame wrapPanelInFrame(JPanel panel, String caption, int width, int height) {
        JFrame frame = new JFrame(caption);
        frame.setSize(width, height);
        frame.add(panel);
        //another way to do this: frame.getContentPane().add(panel, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        return frame;
    }

    public static JFrame wrapPanelInFrame(JFrame frame, JPanel panel, String caption, int width, int height) {
        frame.setTitle(caption);
        frame.setSize(width, height);
        frame.add(panel);
        //another way to do this: frame.getContentPane().add(panel, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        return frame;
    }
}

Related

  1. toFrontHack(JFrame theParent, JFrame theFrame)
  2. toggleFrame(JFrame frame)
  3. toggleOsXFullScreen(JFrame frame)
  4. unpackArchive(URL url, File targetDir, JFrame frame, ProgressMonitor progressMonitor)
  5. waitFor(JFrame popup)
  6. write(JFrame frame, String ext, String desc, String text)
  7. writeOrAbort(String path, JFrame frame)