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:layout.FlowLayoutDemo.java

public static void main(String[] args) {
    /* Use an appropriate Look and Feel */
    try {/*from  w  ww  .  j ava  2 s. co  m*/
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        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 dispatchi thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:CelsiusConverter2.java

public static void main(String[] args) {
    // set the look and feel
    try {//from   www.  ja  v a  2s  .  co m
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) {
    }

    CelsiusConverter2 converter = new CelsiusConverter2();

}

From source file:com.uwsoft.editor.Main.java

public static void main(String[] argv) throws Exception {
    /**//w w w.j a  v a 2  s .c o m
     * this should not be happening when in release mode
     */
    /**
    String input = getLocalArtPath("textures");
    String output = "style";
    String packFileName = "uiskin";
    TexturePacker.Settings settings =  new TexturePacker.Settings();
    settings.flattenPaths = true;
    TexturePacker.processIfModified(input, output, packFileName);
    processSplashScreenTextures();
    */

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

From source file:EditorDropTarget.java

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

    final JFrame f = new JFrame("JEditor Pane Drop Target Example 1");

    JEditorPane pane = new JEditorPane();

    // Add a drop target to the JEditorPane
    EditorDropTarget target = new EditorDropTarget(pane);

    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });

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

From source file:FileTreeDragSource.java

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

    JFrame f = new JFrame("Draggable File Tree");
    try {
        FileTree tree = new FileTree("D:\\");
        f.getContentPane().add(new JScrollPane(tree));

        // Attach the drag source
        FileTreeDragSource dragSource = new FileTreeDragSource(tree);
    } catch (Exception e) {
    }
    f.pack();
    f.setVisible(true);
}

From source file:UndoExample5.java

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

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

    // Create and show a frame monitoring undoable edits
    JFrame undoMonitor = new JFrame("Undo Monitor");
    final JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    undoMonitor.getContentPane().add(new JScrollPane(textArea));
    undoMonitor.setBounds(f.getLocation().x + f.getSize().width, f.getLocation().y, 400, 200);
    undoMonitor.setVisible(true);

    pane.getDocument().addUndoableEditListener(new UndoableEditListener() {
        public void undoableEditHappened(UndoableEditEvent evt) {
            UndoableEdit edit = evt.getEdit();
            textArea.append(edit.getPresentationName() + "(" + edit.toString() + ")\n");
        }
    });

    // Create and show a frame monitoring document edits
    JFrame editMonitor = new JFrame("Edit Monitor");
    final JTextArea textArea2 = new JTextArea();
    textArea2.setEditable(false);
    editMonitor.getContentPane().add(new JScrollPane(textArea2));
    editMonitor.setBounds(undoMonitor.getLocation().x,
            undoMonitor.getLocation().y + undoMonitor.getSize().height, 400, 200);
    editMonitor.setVisible(true);

    pane.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent evt) {
            textArea2.append("Attribute change\n");
        }

        public void insertUpdate(DocumentEvent evt) {
            textArea2.append("Text insertion\n");
        }

        public void removeUpdate(DocumentEvent evt) {
            textArea2.append("Text removal\n");
        }
    });
}

From source file:com.heliosdecompiler.helios.bootloader.Bootloader.java

public static void main(String[] args) {
    try {/*from  ww w  .  j av a 2 s . c o  m*/
        if (!Constants.DATA_DIR.exists() && !Constants.DATA_DIR.mkdirs())
            throw new RuntimeException("Could not create data directory");
        if (!Constants.ADDONS_DIR.exists() && !Constants.ADDONS_DIR.mkdirs())
            throw new RuntimeException("Could not create addons directory");
        if (!Constants.SETTINGS_FILE.exists() && !Constants.SETTINGS_FILE.createNewFile())
            throw new RuntimeException("Could not create settings file");
        if (Constants.DATA_DIR.isFile())
            throw new RuntimeException("Data directory is file");
        if (Constants.ADDONS_DIR.isFile())
            throw new RuntimeException("Addons directory is file");
        if (Constants.SETTINGS_FILE.isDirectory())
            throw new RuntimeException("Settings file is directory");

        try {
            Class<?> clazz = Class.forName("org.eclipse.swt.widgets.Event");
            Object location = clazz.getProtectionDomain() != null
                    && clazz.getProtectionDomain().getCodeSource() != null
                            ? clazz.getProtectionDomain().getCodeSource().getLocation()
                            : "";
            throw new RuntimeException("SWT should not be loaded. Instead, it was loaded from " + location);
        } catch (ClassNotFoundException ignored) {
            loadSWTLibrary();
        }

        DisplayPumper displayPumper = new DisplayPumper();

        if (System.getProperty("os.name").toLowerCase().contains("mac")) {
            System.out.println("Attemting to force main thread");
            Executor executor;
            try {
                Class<?> dispatchClass = Class.forName("com.apple.concurrent.Dispatch");
                Object dispatchInstance = dispatchClass.getMethod("getInstance").invoke(null);
                executor = (Executor) dispatchClass.getMethod("getNonBlockingMainQueueExecutor")
                        .invoke(dispatchInstance);
            } catch (Throwable throwable) {
                throw new RuntimeException("Could not reflectively access Dispatch", throwable);
            }
            if (executor != null) {
                executor.execute(displayPumper);
            } else {
                throw new RuntimeException("Could not load executor");
            }
        } else {
            Thread pumpThread = new Thread(displayPumper);
            pumpThread.setName("Display Pumper");
            pumpThread.start();
        }
        while (!displayPumper.isReady())
            ;

        Display display = displayPumper.getDisplay();
        Shell shell = displayPumper.getShell();
        Splash splashScreen = new Splash(display);
        splashScreen.updateState(BootSequence.CHECKING_LIBRARIES);
        checkPackagedLibrary(splashScreen, "enjarify", Constants.ENJARIFY_VERSION,
                BootSequence.CHECKING_ENJARIFY, BootSequence.CLEANING_ENJARIFY, BootSequence.MOVING_ENJARIFY);
        checkPackagedLibrary(splashScreen, "Krakatau", Constants.KRAKATAU_VERSION,
                BootSequence.CHECKING_KRAKATAU, BootSequence.CLEANING_KRAKATAU, BootSequence.MOVING_KRAKATAU);

        try {
            if (!System.getProperty("os.name").toLowerCase().contains("linux")) {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
        } catch (Exception exception) { //Not important. No point notifying the user
        }

        Helios.main(args, shell, splashScreen);
        synchronized (displayPumper.getSynchronizer()) {
            displayPumper.getSynchronizer().wait();
        }
        System.exit(0);
    } catch (Throwable t) {
        displayError(t);
        System.exit(1);
    }
}

From source file:PanelDropTarget.java

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

    final JFrame f = new JFrame("Component drop target example");

    JPanel pane = new JPanel();

    // Add a drop target to the JPanel
    PanelDropTarget target = new PanelDropTarget(pane);

    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });

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

From source file:com.jsystem.j2autoit.AutoItAgent.java

/**
 * Launch the server side//from  w ww .  j a  va 2s  .c o m
 * 
 * @param args
 */
public static void main(String[] args) {
    try {
        Log.initLog();
        isDebug = AutoItProperties.DEBUG_MODE_KEY.getValue(isDebug);
        isAutoDeleteFiles = AutoItProperties.AUTO_DELETE_TEMPORARY_SCRIPT_FILE_KEY.getValue(isAutoDeleteFiles);
        if (isAutoDeleteFiles) {
            Integer tempHistory = AutoItProperties.AUTO_IT_SCRIPT_HISTORY_SIZE_KEY
                    .getValue(DEFAULT_HistorySize);

            HistoryFile.init();
            HistoryFile.setHistory_Size(tempHistory);
        }
        isForceAutoItShutDown = AutoItProperties.FORCE_AUTO_IT_PROCESS_SHUTDOWN_KEY
                .getValue(isForceAutoItShutDown);
        webServicePort = AutoItProperties.AGENT_PORT_KEY.getValue(webServicePort);
        serverState = AutoItProperties.SERVER_UP_ON_INIT_KEY.getValue(serverState);

        Log.setLogMode(false, isDebug);
        Runtime.getRuntime().addShutdownHook(new ExitThread());
        Log.info(System.getProperty("user.dir") + NEW_LINE);
        Log.info("AutoIt Location: " + getAutoExecuterItLocation("Unable to find") + NEW_LINE);
        startAutoItWebServer(webServicePort);
        if (serverState) {
            serverState = false;
            runWebServer();
        }

        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

    } catch (Exception exception) {
        Log.throwable(exception.getMessage() + NEW_LINE, exception);
    }

    /* Turn off metal's use of bold fonts */
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    //Schedule a job for the event-dispatching thread:
    //adding TrayIcon.
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            createAndShowGUI();
        }
    });
}

From source file:misc.FocusTraversalDemo.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-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}