Example usage for javax.swing UIManager getSystemLookAndFeelClassName

List of usage examples for javax.swing UIManager getSystemLookAndFeelClassName

Introduction

In this page you can find the example usage for javax.swing UIManager getSystemLookAndFeelClassName.

Prototype

public static String getSystemLookAndFeelClassName() 

Source Link

Document

Returns the name of the LookAndFeel class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.

Usage

From source file:base.BasePlayer.AddGenome.java

public static void main(String[] args) {

    try {//from w  ww. ja v a 2 s. c o  m

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    } catch (Exception e) {
        e.printStackTrace();
    }
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:marytts.tools.redstart.AdminWindow.java

/** Sets the GUI look and feel to that of the system (e.g., Windows XP, Mac OS) */
private void setSystemLookAndFeel() {

    // Get the properties from the options file
    Properties options = new Properties();
    try {//from   www .ja  v a  2 s .  c  om
        // First, load defaults from resource in classpath:
        options.load(Redstart.class.getResourceAsStream("user.options"));

        // Then, overwrite from file if present:
        File fileHandle = new File(optionsDialog.getOptionsPathString());
        if (fileHandle.exists()) {
            FileInputStream optionsStream;
            try {
                optionsStream = new FileInputStream(fileHandle);
                options.load(optionsStream);

                // Close the input stream
                optionsStream.close();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    String systemLookAndFeelProp = options.getProperty("systemLookAndFeel");

    if (systemLookAndFeelProp.equals("true")) {

        // Use the look and feel of the system
        try {
            // Set to system look and feel
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        }

    }
}

From source file:ca.uviccscu.lp.server.main.MainFrame.java

/**
 * @param args the command line arguments
 *///from   w  ww .  ja v a  2  s.  c o  m
public static void main(String args[]) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        //
    }
    Logger.getRootLogger().setLevel(Level.ALL);
    Logger.getRootLogger()
            .addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
    PropertyPrinter.main(new String[] {});
    java.awt.EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            new MainFrame().setVisible(true);
        }
    });
}

From source file:ffx.ui.MainPanel.java

/**
 * <p>//  w ww  . j av a2  s .  co  m
 * platformLookAndFeel</p>
 */
public void platformLookAndFeel() {
    try {
        if (SystemUtils.IS_OS_LINUX) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        logger.log(Level.WARNING, "Can''t set look and feel: {0}", e);
    }
}

From source file:jeplus.JEPlusFrameMain.java

private void jMenuItemDefaultLaFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDefaultLaFActionPerformed
    try {/*from  www .  j  a  va2 s  .  c  o  m*/
        switch (jMenuItemDefaultLaF.getActionCommand()) {
        case "default":
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            UIManager.put("swing.boldMetal", Boolean.FALSE);
            SwingUtilities.updateComponentTreeUI(this);
            jMenuItemDefaultLaF.setActionCommand("platform");
            jMenuItemDefaultLaF.setText("Switch to system Look and Feel (OS)");
            this.pack();
            break;
        case "platform":
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            SwingUtilities.updateComponentTreeUI(this);
            jMenuItemDefaultLaF.setActionCommand("default");
            jMenuItemDefaultLaF.setText("Switch to defaul Look and Feel (Metal)");
            this.pack();
            break;
        }
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException ex) {
        logger.error("Error setting Look-and-Feel.", ex);
    }
}

From source file:base.BasePlayer.Main.java

public static void main(String[] args) {
    try {//from   w  w  w.  j  a  va  2 s  .  co m
        UIManager.put("Slider.paintValue", false);
        //   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        System.setProperty("sun.java2d.d3d", "false");
    } catch (Exception e) {
        e.printStackTrace();
    }
    Main.args = args;
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            //Logo.main(argsit);
            createAndShowGUI();
        }
    });
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

public static void main(String[] args) {
    Logger.getRootLogger().addAppender(
            new ConsoleAppender(new org.apache.log4j.PatternLayout("%d - %-5p - %-20c (%C [%L]) - %m%n")));

    GlobalOptions.setSelectedServer("de43");
    DataHolder.getSingleton().loadData(false);
    ProfileManager.getSingleton().loadProfiles();
    GlobalOptions.setSelectedProfile(ProfileManager.getSingleton().getProfiles("de43")[0]);
    TroopsManager.getSingleton().initialize();
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {

            MouseGestures mMouseGestures = new MouseGestures();
            mMouseGestures.setMouseButton(MouseEvent.BUTTON3_MASK);
            mMouseGestures.addMouseGesturesListener(new MouseGestureHandler());
            mMouseGestures.start();/*from ww  w .  ja v  a  2 s .  c  o m*/
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                //  UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                //JFrame.setDefaultLookAndFeelDecorated(true);

                // SubstanceLookAndFeel.setSkin(SubstanceLookAndFeel.getAllSkins().get("Twilight").getClassName());
                //  UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE);
            } catch (Exception e) {
            }
            Logger.getRootLogger().addAppender(new ConsoleAppender(
                    new org.apache.log4j.PatternLayout("%d - %-5p - %-20c (%C [%L]) - %m%n")));

            TribeTribeAttackFrame f = new TribeTribeAttackFrame();
            f.setup();
            f.setSize(600, 400);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
        }
    });
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method initializes defaultItem/*  ww w  .  ja v a  2  s  . c o m*/
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getDefaultMenuItem() {
    if (defaultMenuItem == null) {
        defaultMenuItem = new JMenuItem();
        defaultMenuItem.setText("Default");
        defaultMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    SwingUtilities.updateComponentTreeUI(instance);
                    itSettings.getChild("generalSettings").getChild("graphics").getChild("appearence")
                            .setText("Default");
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
    }
    return defaultMenuItem;
}

From source file:in.gov.uidai.auth.sampleapp.SampleClientMainFrame.java

/**
 * @param args//w  w  w . j a va2  s. com
 *            the command line arguments
 */
public static void main(String args[]) {

    try {
        // Set System L&F
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    } catch (Exception e) {
        e.printStackTrace();
    }

    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            try {
                new SampleClientMainFrame().setVisible(true);

            } catch (URISyntaxException ex) {
                Logger.getLogger(SampleClientMainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:src.gui.ItSIMPLE.java

/**
 * @param argsu/*w  ww. j av a 2  s .c  om*/
 */
public static void main(String[] args) {

    //get CommonDatapddlVer
    Document commonDoc = null;
    try {
        commonDoc = XMLUtilities.readFromFile("resources/settings/commonData.xml");

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (commonDoc != null) {
        commonData = commonDoc.getRootElement();
    }

    // Get settings from itSettings.xml
    org.jdom.Document itSettingsDoc = null;
    try {
        itSettingsDoc = XMLUtilities.readFromFile("resources/settings/itSettings.xml");
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    if (itSettingsDoc != null) {
        itSettings = itSettingsDoc.getRootElement();
    }

    // Get planners from itPlanners
    org.jdom.Document itPlannersDoc = null;
    try {
        itPlannersDoc = XMLUtilities.readFromFile("resources/planners/itPlanners.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (itPlannersDoc != null) {
        itPlanners = itPlannersDoc.getRootElement();
    }

    // Get validators from itValidators
    org.jdom.Document itValidatorsDoc = null;
    try {
        itValidatorsDoc = XMLUtilities.readFromFile("resources/validators/itValidators.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (itPlannersDoc != null) {
        itValidators = itValidatorsDoc.getRootElement();
    }

    try {
        String appearence = itSettings.getChild("generalSettings").getChild("graphics")
                .getChildText("appearence");
        if (appearence.equals("Default")) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else if (appearence.equals("Windows")) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // Windows
        } else if (appearence.equals("Metal")) {
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); // Metal
        } else if (appearence.equals("Motif")) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); // Motif
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }

        // Need installation
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); // GTK+
        //UIManager.setLookAndFeel("javax.swing.plaf.mac.MacLookAndFeel"); // Mac

    } catch (Exception e) {
        //e.printStackTrace();
    }
    SplashScreen splash = new SplashScreen(5000);
    Thread t = new Thread(splash);
    t.start();
    ItSIMPLE.getInstance();

    WindowEventHandler closeWind = new WindowEventHandler();
    closeWind.itsimpleInst = instance;
    instance.addWindowListener(closeWind);
    instance.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    //instance = new ItSIMPLE();
    instance.setVisible(true);
    instance.setExtendedState(JFrame.MAXIMIZED_BOTH);
    //instance.repaint();
    //infoPanel.minimize();

}