Java JFrame run(JFrame frame, int width, int height)

Here you can find the source of run(JFrame frame, int width, int height)

Description

run

License

Open Source License

Declaration

public static void run(JFrame frame, int width, int height) 

Method Source Code

//package com.java2s;
/*/*  w w  w.  j a v  a  2 s .  c  o  m*/
 * This file is part of the QuickServer library 
 * Copyright (C) QuickServer.org
 *
 * Use, modification, copying and distribution of this software is subject to
 * the terms and conditions of the GNU Lesser General Public License. 
 * You should have received a copy of the GNU LGP License along with this 
 * library; if not, you can download a copy from <http://www.quickserver.org/>.
 *
 * For questions, suggestions, bug-reports, enhancement-requests etc.
 * visit http://www.quickserver.org
 *
 */

import javax.swing.*;

public class Main {
    public static void run(JFrame frame, int width, int height) {
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(width, height);
        frame.setVisible(true);
    }

    public static void run(JApplet applet, int width, int height) {
        JFrame frame = new JFrame(title(applet));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(applet);
        frame.setSize(width, height);
        applet.init();
        applet.start();
        frame.setVisible(true);
    }

    public static void run(JPanel panel, int width, int height) {
        JFrame frame = new JFrame(title(panel));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(panel);
        frame.setSize(width, height);
        frame.setVisible(true);
    }

    /**
     * Create a title string from the class name.
     */
    public static String title(Object o) {
        String t = o.getClass().toString();
        // Remove the word "class":
        if (t.indexOf("class") != -1)
            t = t.substring(6);
        if (t.lastIndexOf(".") != -1)
            t = t.substring(t.lastIndexOf(".") + 1);
        return t;
    }
}

Related

  1. renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety)
  2. replaceGlassPane(JFrame frame, Component newGlassPane)
  3. restoreFrame(Class pClass, final JFrame pFrame, String pFrameId)
  4. restoreFrame(JFrame frame)
  5. rightShiftDialog(JDialog dialog, JFrame parent)
  6. saveFrame(Class pClass, JFrame pFrame, String pFrameId)
  7. saveMainWindowLocation(JFrame jfrm, String strPropertiesFilePath, String strPropertiesFileName)
  8. setBlockAllUserInput(final JFrame frame, final boolean yesNo)
  9. setCursorFree(JFrame frame)