Example usage for javax.swing JFrame setDefaultLookAndFeelDecorated

List of usage examples for javax.swing JFrame setDefaultLookAndFeelDecorated

Introduction

In this page you can find the example usage for javax.swing JFrame setDefaultLookAndFeelDecorated.

Prototype

public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) 

Source Link

Document

Provides a hint as to whether or not newly created JFrames should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel.

Usage

From source file:TreeDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./*w  ww . ja  va  2 s .co m*/
 */
private static void createAndShowGUI() {
    if (useSystemLookAndFeel) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.err.println("Couldn't use system look and feel.");
        }
    }

    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("TreeDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:MenuSelectionManagerDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from w  ww  .  j a va 2  s .  c  o m
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("MenuSelectionManagerDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    MenuSelectionManagerDemo demo = new MenuSelectionManagerDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    //Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}

From source file:TreeIconDemo2.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.// w ww  . j ava  2 s.c om
 */
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("TreeIconDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:FrameDemo2.java

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();

    // Handle the New window button.
    if (CREATE_WINDOW.equals(command)) {
        showNewWindow();/*ww w.  ja  v a 2  s .  c  om*/

        // Handle the first group of radio buttons.
    } else if (NO_DECORATIONS.equals(command)) {
        noDecorations = true;
        JFrame.setDefaultLookAndFeelDecorated(false);
    } else if (WS_DECORATIONS.equals(command)) {
        noDecorations = false;
        JFrame.setDefaultLookAndFeelDecorated(false);
    } else if (LF_DECORATIONS.equals(command)) {
        noDecorations = false;
        JFrame.setDefaultLookAndFeelDecorated(true);

        // Handle the second group of radio buttons.
    } else if (DEFAULT_ICON.equals(command)) {
        specifyIcon = false;
    } else if (FILE_ICON.equals(command)) {
        specifyIcon = true;
        createIcon = false;
    } else if (PAINT_ICON.equals(command)) {
        specifyIcon = true;
        createIcon = true;
    }
}

From source file:SplitPaneDemo2.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *//*  w  w  w. j a va2 s.c  o  m*/
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("SplitPaneDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    SplitPaneDemo splitPaneDemo = new SplitPaneDemo();
    frame.getContentPane().add(splitPaneDemo.getSplitPane());

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:components.FrameDemo2.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from w  w w  .j a  va2 s . c o  m
 */
private static void createAndShowGUI() {
    //Use the Java look and feel.
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
    }

    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);

    //Instantiate the controlling class.
    JFrame frame = new JFrame("FrameDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    FrameDemo2 demo = new FrameDemo2();

    //Add components to it.
    Container contentPane = frame.getContentPane();
    contentPane.add(demo.createOptionControls(), BorderLayout.CENTER);
    contentPane.add(demo.createButtonPane(), BorderLayout.PAGE_END);
    frame.getRootPane().setDefaultButton(defaultButton);

    //Display the window.
    frame.pack();
    frame.setLocationRelativeTo(null); //center it
    frame.setVisible(true);
}

From source file:llc.rockford.webcast.EC2Driver.java

private void createAndShowGUI() {
    // Set the look and feel.
    initLookAndFeel();/*from w  w  w.ja  va 2 s  .c  o m*/

    // Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    // Create and set up the window.
    JFrame frame = new JFrame("Webcast Utility");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(300, 400));
    java.net.URL url = ClassLoader.getSystemResource("llc/rockford/webcast/resources/internet.png");
    Toolkit kit = Toolkit.getDefaultToolkit();
    Image img = kit.createImage(url);
    frame.setIconImage(img);
    Component contents = createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);

    // Display the window.
    frame.pack();
    frame.setVisible(true);

}

From source file:FrameDemo2.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *//*www .j  a v a  2 s.  c  o  m*/
private static void createAndShowGUI() {
    // Use the Java look and feel.
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
    }

    // Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);

    // Instantiate the controlling class.
    JFrame frame = new JFrame("FrameDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    FrameDemo2 demo = new FrameDemo2();

    // Add components to it.
    Container contentPane = frame.getContentPane();
    contentPane.add(demo.createOptionControls(), BorderLayout.CENTER);
    contentPane.add(demo.createButtonPane(), BorderLayout.PAGE_END);
    frame.getRootPane().setDefaultButton(defaultButton);

    // Display the window.
    frame.pack();
    frame.setLocationRelativeTo(null); // center it
    frame.setVisible(true);
}

From source file:net.sf.firemox.Magic.java

/**
 * @param args/*w  w  w. ja v a  2  s.c o m*/
 *          the command line arguments
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    Log.init();
    Log.debug("MP v" + IdConst.VERSION + ", jre:" + System.getProperty("java.runtime.version") + ", jvm:"
            + System.getProperty("java.vm.version") + ",os:" + System.getProperty("os.name") + ", res:"
            + Toolkit.getDefaultToolkit().getScreenSize().width + "x"
            + Toolkit.getDefaultToolkit().getScreenSize().height + ", root:" + MToolKit.getRootDir());
    System.setProperty("swing.aatext", "true");
    System.setProperty(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY,
            MToolKit.getIconPath(Play.ZONE_NAME + "/hardwoodfloor.png"));

    final File substancelafFile = MToolKit.getFile(FILE_SUBSTANCE_PROPERTIES);
    if (substancelafFile == null) {
        Log.warn("Unable to locate '" + FILE_SUBSTANCE_PROPERTIES
                + "' file, you are using the command line with wrong configuration. See http://www.firemox.org/dev/project.html documentation");
    } else {
        System.getProperties().load(new FileInputStream(substancelafFile));
    }
    MToolKit.defaultFont = new Font("Arial", 0, 11);
    try {
        if (args.length > 0) {
            final String[] args2 = new String[args.length - 1];
            System.arraycopy(args, 1, args2, 0, args.length - 1);
            if ("-rebuild".equals(args[0])) {
                XmlConfiguration.main(args2);
            } else if ("-oracle2xml".equals(args[0])) {
                Oracle2Xml.main(args2);
            } else if ("-batch".equals(args[0])) {
                if ("-server".equals(args[1])) {
                    batchMode = BATCH_SERVER;
                } else if ("-client".equals(args[1])) {
                    batchMode = BATCH_CLIENT;
                }
            } else {
                Log.error("Unknown options '" + Arrays.toString(args)
                        + "'\nUsage : java -jar starter.jar <options>, where options are :\n"
                        + "\t-rebuild -game <tbs name> [-x] [-d] [-v] [-h] [-f] [-n]\n"
                        + "\t-oracle2xml -f <oracle file> -d <output directory> [-v] [-h]");
            }
            System.exit(0);
            return;
        }
        if (batchMode == -1 && !"Mac OS X".equals(System.getProperty("os.name"))) {
            splash = new SplashScreen(MToolKit.getIconPath("splash.jpg"), null, 2000);
        }

        // language settings
        LanguageManager.initLanguageManager(Configuration.getString("language", "auto"));
    } catch (Throwable t) {
        Log.error("START-ERROR : \n\t" + t.getMessage());
        System.exit(1);
        return;
    }
    Log.debug("MP Language : " + LanguageManager.getLanguage().getName());
    speparateAvatar = Toolkit.getDefaultToolkit().getScreenSize().height > 768;

    // verify the java version, minimal is 1.5
    if (new JavaVersion().compareTo(new JavaVersion(IdConst.MINIMAL_JRE)) == -1) {
        Log.error(LanguageManager.getString("wrongjava") + IdConst.MINIMAL_JRE);
    }

    // load look and feel settings
    lookAndFeelName = Configuration.getString("preferred", MUIManager.LF_SUBSTANCE_CLASSNAME);
    // try {
    // FileInputStream in= new FileInputStream("MAGIC.TTF");
    // MToolKit.defaultFont= Font.createFont(Font.TRUETYPE_FONT, in);
    // in.close();
    // MToolKit.defaultFont= MToolKit.defaultFont.deriveFont(Font.BOLD, 11);
    // }
    // catch (FileNotFoundException e) {
    // System.out.println("editorfont.ttf not found, using default.");
    // }
    // catch (Exception ex) {
    // ex.printStackTrace();
    // }

    // Read available L&F
    final LinkedList<Pair<String, String>> lfList = new LinkedList<Pair<String, String>>();
    try {
        BufferedReader buffReader = new BufferedReader(
                new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_THEME_SETTINGS)));
        String line;
        while ((line = buffReader.readLine()) != null) {
            line = line.trim();
            if (!line.startsWith("#")) {
                final int index = line.indexOf(';');
                if (index != -1) {
                    lfList.add(new Pair<String, String>(line.substring(0, index), line.substring(index + 1)));
                }
            }
        }
        IOUtils.closeQuietly(buffReader);
    } catch (Throwable e) {
        // no place for resolve this problem
        Log.debug("Error reading L&F properties : " + e.getMessage());
    }
    for (Pair<String, String> pair : lfList) {
        UIManager.installLookAndFeel(pair.key, pair.value);
    }

    // install L&F
    if (SkinLF.isSkinLF(lookAndFeelName)) {
        // is a SkinLF Look & Feel
        /*
         * Make sure we have a nice window decoration.
         */
        SkinLF.installSkinLF(lookAndFeelName);
    } else {
        // is Metal Look & Feel
        if (!MToolKit.isAvailableLookAndFeel(lookAndFeelName)) {
            // preferred look&feel is not available
            JOptionPane.showMessageDialog(magicForm,
                    LanguageManager.getString("preferredlfpb", lookAndFeelName),
                    LanguageManager.getString("error"), JOptionPane.INFORMATION_MESSAGE);
            setDefaultUI();
        }

        // Install the preferred
        LookAndFeel newLAF = MToolKit.geLookAndFeel(lookAndFeelName);
        frameDecorated = newLAF.getSupportsWindowDecorations();

        /*
         * Make sure we have a nice window decoration.
         */
        JFrame.setDefaultLookAndFeelDecorated(frameDecorated);
        JDialog.setDefaultLookAndFeelDecorated(frameDecorated);
        UIManager.setLookAndFeel(MToolKit.geLookAndFeel(lookAndFeelName));
    }

    // Start main thread
    try {
        new Magic();
        SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER);
    } catch (Throwable e) {
        Log.fatal("In main thread, occurred exception : ", e);
        ConnectionManager.closeConnexions();
        return;
    }
}

From source file:TextInputDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//  w ww.  j  a  va 2  s  .  c o  m
 */
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("TextInputDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}