Example usage for javax.swing UIManager setLookAndFeel

List of usage examples for javax.swing UIManager setLookAndFeel

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, UnsupportedLookAndFeelException 

Source Link

Document

Loads the LookAndFeel specified by the given class name, using the current thread's context class loader, and passes it to setLookAndFeel(LookAndFeel) .

Usage

From source file:br.usp.poli.lta.cereda.wsn2spa.Main.java

public static void main(String[] args) {

    Utils.printBanner();//  w  w w .j  av  a 2s.  co  m
    CommandLineParser parser = new DefaultParser();

    try {

        CommandLine line = parser.parse(Utils.getOptions(), args);

        if (line.hasOption("g")) {
            System.out.println("Flag '-g' found, overriding other flags.");
            System.out.println("Please, wait...");
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception nothandled) {
            }
            SwingUtilities.invokeLater(() -> {
                Editor e = new Editor();
                e.setVisible(true);
            });
        } else {
            enableCLI(line);
        }
    } catch (ParseException nothandled) {
        Utils.printHelp();
    } catch (Exception exception) {
        Utils.printException(exception);
    }
}

From source file:events.MouseEventDemo.java

public static void main(String[] args) {
    /* Use an appropriate Look and Feel */
    try {/*from w ww  .j  ava2 s.  c o m*/
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex) {
        ex.printStackTrace();
    } catch (InstantiationException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    }
    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:ua.com.fielden.platform.example.swing.booking.BookingChartPanelExample.java

public static void main(final String[] args) {
    SwingUtilitiesEx.invokeLater(new Runnable() {

        @Override//from w w w  . j a v  a2 s  . co  m
        public void run() {
            for (final LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(laf.getName())) {
                    try {
                        UIManager.setLookAndFeel(laf.getClassName());
                    } catch (final Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            com.jidesoft.utils.Lm.verifyLicense("Fielden Management Services", "Rollingstock Management System",
                    "xBMpKdqs3vWTvP9gxUR4jfXKGNz9uq52");
            LookAndFeelFactory.installJideExtension();
            final JFrame frame = new JFrame("Booking chart demo");
            final JLabel label = new JLabel("None");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLayout(new MigLayout("fill, insets 0", "[grow, fill]", "[grow, fill][]"));
            frame.add(createBookingChartPanel(label), "wrap");
            frame.add(label);
            frame.setPreferredSize(new Dimension(640, 480));
            frame.pack();
            frame.setVisible(true);
        }
    });
}

From source file:events.MouseMotionEventDemo.java

public static void main(String[] args) {
    /* Use an appropriate Look and Feel */
    try {/*  w  w  w. j av  a  2  s .  com*/
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex) {
        ex.printStackTrace();
    } catch (InstantiationException ex) {

        ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    }
    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);

    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:events.KeyEventDemo.java

public static void main(String[] args) {
    /* Use an appropriate Look and Feel */
    try {//  w ww  .  j  a va2  s  .c om
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex) {
        ex.printStackTrace();
    } catch (InstantiationException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    }
    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);

    //Schedule a job for event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:events.MouseWheelEventDemo.java

public static void main(String[] args) {
    /* Use an appropriate Look and Feel */
    try {//  w w w  .  ja va 2 s.co  m
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (IllegalAccessException ex) {
        ex.printStackTrace();
    } catch (InstantiationException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
    }
    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);

    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:avoking.com.documentos.scheduler.startup.Main.java

public static void main(String[] args) {
    //        SplashWindow s = new SplashWindow("E:\\Documentos\\NetBeansProjects\\documentos.scheduler.core\\src\\main\\java\\avoking\\com\\documentos\\scheduler\\startup\\SplashScreen reducida.png", null, 10000);
    //        s.setVisible(true);
    //      //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    try {//w  w  w .  j a v  a  2 s  . co  m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>  

    try {
        FileInputStream fis = new FileInputStream(
                "E:\\Avo-King\\Documentos\\Desarrollo\\PROCEDIMIENTO_Pruebas_RH\\PDRH-05.docx");
        XWPFDocument xdoc = new XWPFDocument(OPCPackage.open(fis));
        XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(xdoc);
        //read header
        XWPFHeader header = policy.getDefaultHeader();
        System.out.println(StringEscapeUtils.escapeJava(header.getText()));
        //            //read footer
        //            XWPFFooter footer = policy.getDefaultFooter();
        //            System.out.println(footer.getText());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    //        Main m = new Main();
    //        m.execute();
    //        splashLoading.getContentPane().setBackground(Color.WHITE);
    //        splashLoading.pnlProgress.setBackground(Color.WHITE);
    //        splashLoading.setLocationRelativeTo(null);
    //        splashLoading.setVisible(true);
}

From source file:de.alpharogroup.duplicate.files.desktoppane.MainApplication.java

/**
 * The main method.//from ww w.  ja va 2s .c o  m
 *
 * @param args
 *            the arguments
 */
public static void main(final String[] args) {

    final ApplicationContext ctx = SpringApplicationContext.getInstance().getApplicationContext();
    final Resource resource = ctx.getResource("classpath:conf/log4j/log4jconfig.xml");

    try {
        DOMConfigurator.configure(resource.getURL());
    } catch (final FactoryConfigurationError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    final MainFrame mainFrame = MainFrame.getInstance();
    final DesktopMenu menu = DesktopMenu.getInstance();
    mainFrame.setJMenuBar(menu.getMenubar());

    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setSize(ScreenSizeExtensions.getScreenWidth(), ScreenSizeExtensions.getScreenHeight());
    mainFrame.setVisible(true);
    mainFrame.getDesktopPane().getDesktopManager().activateFrame(mainFrame.getInternalFrame());
    mainFrame.getDesktopPane().getDesktopManager().maximizeFrame(mainFrame.getInternalFrame());
    mainFrame.getInternalFrame().toFront();

    // Set default look and feel...
    try {
        UIManager.setLookAndFeel(LookAndFeels.SYSTEM.getLookAndFeelName());
        SwingUtilities.updateComponentTreeUI(mainFrame);
        mainFrame.setCurrentLookAndFeels(LookAndFeels.SYSTEM);
    } catch (final ClassNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (final InstantiationException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (final IllegalAccessException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (final UnsupportedLookAndFeelException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}

From source file:QandE.Test1.java

public static void main(String[] args) {
    try {//from   w  w w.  j  av a  2s  .  co m
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
    }

    //Create the top-level container and add contents to it.
    JFrame frame = new JFrame("Test1");
    Test1 app = new Test1();
    Component contents = app.createComponents();
    frame.getContentPane().add(contents, BorderLayout.CENTER);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:havocx42.Program.java

public static void main(String[] args) throws ParseException {
    try {//w  w w  . j  a v a2 s . c  o m
        initRootLogger();
    } catch (SecurityException | IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return;
    }
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e1) {
        LOGGER.log(Level.WARNING, "Unable to set Look and Feel", e1);
    }

    Options options = new Options();
    options.addOption("nogui", false,
            "run as a command line tool, must also supply -target and -source arguments");
    options.addOption("source", true, "source directory where the PR weapons folder has been extracted");
    options.addOption("target", true, "target file to write to");
    options.addOption("version", false, "print the version information and exit");
    options.addOption("help", false, "print this message");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("version")) {
        System.out.println("PRStats " + VERSION);
        System.out.println("Written by havocx42");
        return;
    }

    if ((cmd.hasOption("nogui") && (!cmd.hasOption("source") || !cmd.hasOption("target")))
            || cmd.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("PRStats", options);
        return;
    }

    final String target;
    final String source;

    source = cmd.getOptionValue("source");
    target = cmd.getOptionValue("target");
    LOGGER.info("Source Argument: " + source);
    LOGGER.info("Target Argument: " + target);

    if (!cmd.hasOption("nogui")) {
        EventQueue.invokeLater(new Runnable() {
            @SuppressWarnings("unused")
            public void run() {
                try {
                    Gui window = new Gui(source, target);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        return;
    }

    File targetFile = new File(target);
    File sourceFile = new File(source);
    Controller controller = new Controller();
    controller.run(sourceFile, targetFile);

}