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:ExtendedParagraphExample.java

public static void main(String[] args) {
    try {/*from  w w w .ja va2s.c  o m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new JFrame("Extended Paragraph Example");

    // Create the StyleContext, the document and the pane
    final StyleContext sc = new StyleContext();
    final DefaultStyledDocument doc = new DefaultStyledDocument(sc);
    final JTextPane pane = new JTextPane(doc);
    pane.setEditorKit(new ExtendedStyledEditorKit());

    try {
        // Add the text and apply the styles
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                // Build the styles
                createDocumentStyles(sc);

                // Add the text
                addText(pane, sc, sc.getStyle(mainStyleName), content);
            }
        });
    } catch (Exception e) {
        System.out.println("Exception when constructing document: " + e);
        System.exit(1);
    }

    f.getContentPane().add(new JScrollPane(pane));
    f.setSize(400, 300);
    f.setVisible(true);
}

From source file:misc.TablePrintDemo3.java

/**
 * Start the application.//from   w ww .ja  v a2s .c om
 */
public static void main(final String[] args) {
    /* Schedule for the GUI to be created and shown on the EDT */
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            /* Don't want bold fonts if we end up using metal */
            UIManager.put("swing.boldMetal", false);
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
            }
            new TablePrintDemo3().setVisible(true);
        }
    });
}

From source file:EditorPaneExample4.java

public static void main(String[] args) {
    try {//from   w  w w . j a  v a 2s .  c  o  m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new EditorPaneExample4();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:fll.scheduler.SchedulerUI.java

public static void main(final String[] args) {
    LogUtils.initializeLogging();//from  w  w  w  .  j  av a 2  s.  c  om

    Thread.setDefaultUncaughtExceptionHandler(new GuiExceptionHandler());

    // Use cross platform look and feel so that things look right all of the
    // time
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (final ClassNotFoundException e) {
        LOGGER.warn("Could not find cross platform look and feel class", e);
    } catch (final InstantiationException e) {
        LOGGER.warn("Could not instantiate cross platform look and feel class", e);
    } catch (final IllegalAccessException e) {
        LOGGER.warn("Error loading cross platform look and feel", e);
    } catch (final UnsupportedLookAndFeelException e) {
        LOGGER.warn("Cross platform look and feel unsupported?", e);
    }

    try {
        final SchedulerUI frame = new SchedulerUI();

        frame.addWindowListener(new WindowAdapter() {
            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void windowClosing(final WindowEvent e) {
                System.exit(0);
            }

            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void windowClosed(final WindowEvent e) {
                System.exit(0);
            }
        });
        // should be able to watch for window closing, but hidden works
        frame.addComponentListener(new ComponentAdapter() {
            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void componentHidden(final ComponentEvent e) {
                System.exit(0);
            }
        });

        GraphicsUtils.centerWindow(frame);

        frame.setVisible(true);
    } catch (final Exception e) {
        LOGGER.fatal("Unexpected error", e);
        JOptionPane.showMessageDialog(null,
                "An unexpected error occurred. Please send the log file and a description of what you were doing to the developer. Error message: "
                        + e.getMessage(),
                "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:layout.Find.java

public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
                //  "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                //UIManager.getCrossPlatformLookAndFeelClassName());
            } catch (Exception ex) {
                ex.printStackTrace();/*from w  ww  .j a  va 2  s  .  c o  m*/
            }
            new Find().setVisible(true);
        }
    });
}

From source file:PaginationExample.java

public static void main(String args[]) {

    try {//from w ww.j av a  2 s  .c o m
        String cn = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(cn); // Use the native L&F
    } catch (Exception cnf) {
    }
    JFrame f = new JFrame("Printing Pagination Example");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JButton printButton = new JButton("Print Pages");
    printButton.addActionListener(new PaginationExample());
    f.add("Center", printButton);
    f.pack();
    f.setVisible(true);
}

From source file:brainflow.core.ImageBrowser.java

public static void main(String[] args) {
    com.jidesoft.utils.Lm.verifyLicense("UIN", "BrainFlow", "S5XiLlHH0VReaWDo84sDmzPxpMJvjP3");
    //com.jidesoft.plaf.LookAndFeelFactory.installDefaultLookAndFeel();
    //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2007_STYLE);

    URL url1 = BF.getDataURL("data/icbm452_atlas_probability_insula.hdr");
    URL url2 = BF.getDataURL("data/icbm452_atlas_probability_white.hdr");

    try {//from w  w  w  .j a  v  a  2  s. com
        UIManager.setLookAndFeel(new NimbusLookAndFeel());
        IImageSource dsource1 = BrainIO.loadDataSource(VFS.getManager().resolveFile(url1.toURI().toString()));
        IImageSource dsource2 = BrainIO.loadDataSource(VFS.getManager().resolveFile(url2.toURI().toString()));
        ImageBrowser browser = new ImageBrowser(Arrays.asList(dsource1, dsource2));
        JFrame frame = new JFrame();
        frame.add(browser, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);

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

    //List<IImageDataSource> dsource2 = BrainIO.loadDataSources(new File("/home/brad/data/sub30072/anat/mprage_anonymized.nii.gz"),
    //                         new File("/home/brad/data/sub54329/anat/mprage_anonymized.nii.gz"));

    // List<List<IImageDataSource>> sourceList = Arrays.asList(dsource1, dsource2);

    // ImageBrowser browser = new ImageBrowser(sourceList);
    //  JFrame frame = new JFrame();
    // frame.add(browser, BorderLayout.CENTER);
    //  frame.pack();
    // frame.setVisible(true);

}

From source file:esg.node.publisher_fe.Main.java

public static void main(String[] args) {
    try {//from   w ww.  j  a va2  s . c  om
        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);

    ESGPublisher ESG = new ESGPublisher();
    ESG.buildPublisher();
    System.out.println("done");
}

From source file:io.uploader.drive.DriveUploader.java

public static void main(String[] args) {

    if (isMacOsX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name",
                Configuration.INSTANCE.getAppName());
        try {/*from   w w  w.j  a va 2 s  . c o m*/
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            logger.error("Error occurred while initializing the UI", e);
        }
    }

    Platform.setImplicitExit(false);

    // load the settings
    String settingsFile = "driveuploader-settings.xml";
    if (!new java.io.File(settingsFile).exists())
        settingsFile = null;
    try {
        Configuration.INSTANCE.load(settingsFile);
    } catch (ConfigurationException e) {
        logger.error("Error occurred while initializing the configuration", e);
    }

    try {
        // initialize the transport
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        // initialize the data store factory
        dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);

    } catch (IOException e) {
        logger.error("Error occurred while initializing the drive", e);
        Platform.exit();
    } catch (Throwable t) {
        logger.error("Error occurred while initializing the drive", t);
        Platform.exit();
    }

    launch(args);
}

From source file:com.o2d.pkayjava.editor.Main.java

public static void main(String[] argv) throws Exception {
    /**/*www .  jav a2 s  . co  m*/
     * this should not be happening when in release mode
     */
    /**
    */

    new Main();
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}