Example usage for javax.swing UIManager getInstalledLookAndFeels

List of usage examples for javax.swing UIManager getInstalledLookAndFeels

Introduction

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

Prototype

public static LookAndFeelInfo[] getInstalledLookAndFeels() 

Source Link

Document

Returns an array of LookAndFeelInfo s representing the LookAndFeel implementations currently available.

Usage

From source file:uk.co.modularaudio.componentdesigner.ComponentDesignerLauncher.java

public static void main(final String[] args) throws Exception {
    FontResetter.turnOnGlobalAaText();/*  w w  w.j av  a  2 s  .  co m*/

    boolean useSystemLookAndFeel = false;

    boolean showAlpha = false;
    boolean showBeta = false;
    String additionalBeansResource = null;
    String additionalConfigResource = null;

    String configResourcePath = CDCONFIG_PROPERTIES;

    if (args.length > 0) {
        for (int i = 0; i < args.length; ++i) {
            final String arg = args[i];
            if (arg.equals("--useSlaf")) {
                useSystemLookAndFeel = true;
            } else if (arg.equals("--beta")) {
                showBeta = true;
            } else if (arg.equals("--alpha")) {
                showAlpha = true;
                showBeta = true;
            } else if (arg.equals("--pluginJar")) {
                additionalBeansResource = PLUGIN_BEANS_RESOURCE_PATH;
                additionalConfigResource = PLUGIN_CONFIG_RESOURCE_PATH;

                if (log.isDebugEnabled()) {
                    log.debug("Will append plugin beans: " + additionalBeansResource);
                    log.debug("Will append plugin config file: " + additionalConfigResource);
                }
            } else if (arg.equals("--development")) {
                // Let me specify certain things with hard paths
                configResourcePath = CDDEVELOPMENT_PROPERTIES;
                log.info("In development mode. Will use development properties for configuration");
            } else if (arg.equals("--jprofiler")) {
                configResourcePath = CDJPROFILER_PROPERTIES;
                log.info("In jprofiler mode - using jprofiler properties for configuration");
            } else {
                final String msg = "Unknown command line argument: " + arg;
                log.error(msg);
                throw new DatastoreException(msg);
            }
        }
        if (useSystemLookAndFeel) {
            log.info("System look and feel activated");
        }
        if (showAlpha) {
            log.info("Showing alpha components");
        }
        if (showBeta) {
            log.info("Showing beta components");
        }
    }

    if (useSystemLookAndFeel) {
        final String gtkLookAndFeelClassName = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        boolean foundGtkLaf = false;

        final LookAndFeelInfo lafis[] = UIManager.getInstalledLookAndFeels();

        for (final LookAndFeelInfo lafi : lafis) {
            final String lc = lafi.getClassName();
            if (lc.equals(gtkLookAndFeelClassName)) {
                foundGtkLaf = true;
                break;
            }
        }

        if (foundGtkLaf) {
            log.debug("Found available GTK laf. Will set active");
            UIManager.setLookAndFeel(gtkLookAndFeelClassName);
        }
        UIManager.put("Slider.paintValue", Boolean.FALSE);
    }

    final Font f = Font.decode("");
    final String fontName = f.getName();
    FontResetter.setUIFontFromString(fontName, Font.PLAIN, 10);

    log.debug("ComponentDesigner starting.");
    // Set the fft library to only use current thread
    JTransformsConfigurator.setThreadsToOne();

    final ComponentDesignerLauncher application = new ComponentDesignerLauncher();
    application.init(configResourcePath, additionalBeansResource, additionalConfigResource, showAlpha,
            showBeta);

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            try {
                application.go();
                application.registerCloseAction();
            } catch (final Exception e) {
                final String msg = "Exception caught at top level of ComponentDesigner launch: " + e.toString();
                log.error(msg, e);
                System.exit(0);
            }
            log.debug("Leaving runnable run section.");
        }
    });
}

From source file:unikn.dbis.univis.explorer.VExplorer.java

License:asdf

private void initMenuBar() {

    JMenuBar menuBar = new JMenuBar();

    VMenu program = new VMenu(Constants.PROGRAM);

    VMenuItem schemaImport = new VMenuItem(Constants.SCHEMA_IMPORT, VIcons.SCHEMA_IMPORT);
    schemaImport.setAccelerator(KeyStroke.getKeyStroke('I', Event.CTRL_MASK));
    schemaImport.addActionListener(new ActionListener() {
        /**// w  w  w.  j  a va  2 s. c o  m
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();

            fileChooser.addChoosableFileFilter(new FileFilter() {

                /**
                 * Whether the given file is accepted by this filter.
                 */
                public boolean accept(File f) {
                    return f.getName().endsWith(".vs.xml") || f.isDirectory();
                }

                /**
                 * The description of this filter. For example: "JPG and GIF Images"
                 *
                 * @see javax.swing.filechooser.FileView#getName
                 */
                public String getDescription() {
                    return "UniVis Schema (*.vs.xml)";
                }
            });

            int option = fileChooser.showOpenDialog(VExplorer.this);

            if (option == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                new SchemaImport(file);
                refreshTree();
                JOptionPane.showMessageDialog(VExplorer.this, "Schema Import erfolgreich beendet.",
                        "Schema Import", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    program.add(schemaImport);
    program.addSeparator();

    VMenuItem exit = new VMenuItem(Constants.EXIT, VIcons.EXIT);
    exit.setAccelerator(KeyStroke.getKeyStroke('Q', Event.ALT_MASK));
    exit.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    program.add(exit);

    VMenu lafMenu = new VMenu(Constants.LOOK_AND_FEEL);

    ButtonGroup lafGroup = new ButtonGroup();
    for (final UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        JRadioButtonMenuItem lafMenuItem = new JRadioButtonMenuItem(laf.getName());

        // Set the current Look And Feel as selected.
        if (UIManager.getLookAndFeel().getName().equals(laf.getName())) {
            lafMenuItem.setSelected(true);
        }

        lafMenuItem.addActionListener(new ActionListener() {
            /**
             * Invoked when an action occurs.
             */
            public void actionPerformed(ActionEvent e) {
                updateLookAndFeel(laf.getClassName());
            }
        });

        lafGroup.add(lafMenuItem);
        lafMenu.add(lafMenuItem);
    }

    JMenu questionMark = new JMenu("?");

    VMenuItem license = new VMenuItem(Constants.LICENSE);
    license.addActionListener(new ActionListener() {

        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            new LicenseDialog(VExplorer.this);
        }
    });
    questionMark.add(license);

    final VMenuItem about = new VMenuItem(Constants.ABOUT, VIcons.INFORMATION);
    about.addActionListener(new ActionListener() {

        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            new AboutPanel(VExplorer.this);
        }
    });
    questionMark.add(about);

    menuBar.add(program);
    menuBar.add(lafMenu);
    menuBar.add(questionMark);

    setJMenuBar(menuBar);
}

From source file:yadrone.DroneGUI.java

/**
 * Constructor//from w  w w.  jav a 2  s  .  c  o  m
 *
 * @param drone Drone object
 * @param pil Image panel with processed image stream
 * @param cont DroneControl object for receiving navigation data
 * @param regulator Object for reading and setting PID parameters
 * @param cd Object for reading and setting thresholding parameters
 */
public DroneGUI(IARDrone drone, DroneControl cont, ProcessedImagePanel pil, TimerTask regulator,
        CircleDetection cd, int[] resolution) {
    this.drone = drone;
    this.cont = cont;
    this.pil = pil;
    this.regulator = (Regulator) regulator;
    this.cd = cd;
    v1 = new VideoListener(drone, resolution);
    navData = new NavDataListener(drone);
    try {
        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
        }

    }
    df.setRoundingMode(RoundingMode.CEILING);
    initComponents();
    updateTextFields();
    this.setVisible(true);
}

From source file:zxmax.tools.timerreview.Main.java

public Main() throws Exception {

    MyUncaughtExceptionHandler myUncaughtExceptionHandler = new MyUncaughtExceptionHandler(LOGGER);

    Thread.setDefaultUncaughtExceptionHandler(myUncaughtExceptionHandler);
    final TrayIcon trayIcon = getTrayIcon();
    final TrayIconMouseMotionListener listener = new TrayIconMouseMotionListener(trayIcon);
    trayIcon.addMouseMotionListener(listener);

    Register.put(TrayIcon.class, trayIcon);
    Register.put(TrayIconMouseMotionListener.class, listener);
    String implementationVersion = zxmax.tools.timerreview.Main.class.getPackage().getImplementationVersion();
    Register.put(ApplicationInfo.class, new ApplicationInfo(implementationVersion));

    // ObjectValidator[] validators = new ObjectValidator[] {
    // new TomatoValidator(), new TomatoReviewValidator() };

    Map<Class, ObjectValidator> validationCommands = new HashedMap();
    validationCommands.put(Tomato.class, new TomatoValidator());
    validationCommands.put(TomatoReview.class, new TomatoReviewValidator());

    Register.put(ValidatorService.class, new ValidatorService(validationCommands));

    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }/*  w w w . j  a  v  a2 s.c o m*/
    }

    final StartTimerWindow timer = new StartTimerWindow();
    timer.setVisible(true);
    timer.createBufferStrategy(1);

    // HibernateBasicDaoImpl basicDao = new HibernateBasicDaoImpl();
    // Register.put(HibernateBasicDaoImpl.class, basicDao);

}