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:serial.ChartFromSerial.java

/**
 * Creates new form JavaArduinoInterfacingAttempt
 *//*from  w  ww  .  ja  v  a  2 s  .c om*/
public ChartFromSerial() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println(e);
    }
    initComponents();

    //set autoscroll
    autoScroll_chkBx.setSelected(true);
    autoScrollEnabled = true;

    //create the graph
    defaultSeries = new XYSeries(graphName);
    defaultDataset = new XYSeriesCollection(defaultSeries);
    defaultChart = ChartFactory.createXYLineChart(graphName, xAxisLabel, yAxisLabel, defaultDataset);
    graph = new ChartPanel(defaultChart);
    chartPanel.add(graph, BorderLayout.CENTER);
    graph.setVisible(true);

    //create the text log
    text = new JTextArea();
    text.setEditable(false);
    textScrollPane = new JScrollPane(text);
    textScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    textPanel.add(textScrollPane, BorderLayout.CENTER);
    textScrollPane.setVisible(true);

    //Populate the combo box
    portNames = SerialPort.getCommPorts();
    while (portNames.length == 0) {
        if (JOptionPane.showConfirmDialog(rootPane, "No connected devices found.\nWould you like to refresh?",
                "Could not connect to any devices.", JOptionPane.YES_NO_OPTION,
                JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) {
            buttonsOff();
            return;
        } else {
            portNames = SerialPort.getCommPorts();
        }
    }
    portList_jCombo.removeAllItems();
    for (SerialPort portName : portNames) {
        portList_jCombo.addItem(portName.getSystemPortName());
    }
}

From source file:de.fhg.igd.swingrcp.SwingRCPUtilities.java

/**
 * Setup Look and Feel to match SWT looks
 *//*from   w  w  w.j  a v  a2s  . co m*/
public static void setupLookAndFeel() {
    if (!lafInitialized) {
        String laf;
        if (Platform.WS_GTK.equals(Platform.getWS())) {
            /*
             * Work-around for Eclipse Bug 341799
             * https://bugs.eclipse.org/bugs/show_bug.cgi?id=341799
             *
             * A LookAndFeel other than the GTK look and feel has to be used
             * when using GTK as window managing system in SWT, as access to
             * GTK of ATW/Swing and SWT is not synchronized.
             */
            laf = "javax.swing.plaf.metal.MetalLookAndFeel";
        } else {
            laf = SwingRCPPlugin.getCustomLookAndFeel();

            if (laf == null) {
                laf = UIManager.getSystemLookAndFeelClassName();
            }
        }

        try {
            UIManager.setLookAndFeel(laf);
            log.info("Set look and feel to " + laf);
        } catch (Exception e) {
            log.error("Error setting look and feel: " + laf, e);
        }

        lafInitialized = true;
    }
}

From source file:namedatabasescraper.NameDatabaseScraper.java

public NameDatabaseScraper() throws Exception {
    NameDatabaseScraper.application = this;

    // First setup our logger
    this.checkSettingsDirExists();
    logger.setLevel(Level.INFO);/* ww w.  j av a  2  s  . c  o  m*/
    FileHandler fh = new FileHandler(this.settingsDirname + File.separator + "debug.log", 8096, 1, false);
    logger.addHandler(fh);
    SimpleFormatter formatter = new SimpleFormatter();
    fh.setFormatter(formatter);
    logger.info("Starting NameDatabaseScraper");

    // Load our properties and attach the database, creating it if it doesn't exist
    this.loadProperties();
    this.attachDatabase();

    // Create our GUI
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    window = new MainWindow(this);
    window.setLocationRelativeTo(null);
    window.setTitle("NameDatabaseScraper");
    window.setVisible(true);
}

From source file:de.atomfrede.tools.evalutation.ui.AppWindow.java

static void setLookAndFeel() {
    try {//from w ww  . java 2 s .  c  o m
        // Set System L&F
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    } catch (UnsupportedLookAndFeelException e) {
        // handle exception
    } catch (ClassNotFoundException e) {
        // handle exception
    } catch (InstantiationException e) {
        // handle exception
    } catch (IllegalAccessException e) {
        // handle exception
    }
}

From source file:net.mybox.mybox.ClientGUI.java

/** Creates new form ClientAWT */
public ClientGUI(String configFile) {

    // try to make the swing components look better
    try {//from  w w  w.  j a  v a  2s.  c o m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {

    }

    this.setTitle("Mybox Preferences");

    initComponents();
    jTabbedPrefs.setSelectedIndex(1); // show the messages first

    client = new Client();
    client.Config(configFile);
    client.clientGui = this;

    placeTrayIconAWT();

    if (!debugMode)
        client.start();

    this.setVisible(debugMode);
}

From source file:chibi.gemmaanalysis.cli.deprecated.ProbeMapperGui.java

/**
 * @param args//from  ww  w .  java  2s.  co m
 */
public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
        e.printStackTrace();
    }
    ProbeMapperGui pgmg = new ProbeMapperGui();

    pgmg.pack();
    pgmg.setVisible(true);

}

From source file:com.github.cmisbox.ui.UI.java

private UI() {
    this.log = LogFactory.getLog(this.getClass());
    try {//from  w ww  . jav  a 2 s .com
        this.available = !GraphicsEnvironment.isHeadless();

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        if (SystemTray.isSupported()) {

            this.tray = SystemTray.getSystemTray();
            Image image = ImageIO.read(this.getClass().getResource("images/cmisbox.png"));

            ActionListener exitListener = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    Main.exit(0);
                }
            };

            this.popup = new PopupMenu();
            MenuItem defaultItem = new MenuItem(Messages.exit);
            defaultItem.addActionListener(exitListener);
            this.popup.add(defaultItem);

            MenuItem loginItem = new MenuItem(Messages.login);
            loginItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    new LoginDialog();
                }
            });
            this.popup.add(loginItem);

            MenuItem treeItem = new MenuItem(Messages.showTree);
            treeItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    new TreeSelect();
                }
            });

            this.popup.add(treeItem);

            final TrayIcon trayIcon = new TrayIcon(image, UI.NOTIFY_TITLE, this.popup);

            trayIcon.setImageAutoSize(true);

            this.tray.add(trayIcon);

            this.notify(Messages.startupComplete);

        }

    } catch (Exception e) {
        this.log.error(e);
    }
}

From source file:net.sf.translate64.util.TranslateUtils.java

/**
 * Set the native look and feel./*from  ww  w.j a  va 2 s .  c  o  m*/
 */
public static void setNativeLookAndFeel() {

    // let's try
    try {

        // set the default look and feel as the system look and feel
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {

        // something happened, but do nothing
    }
}

From source file:item.analysis.report.MainFrame.java

/**
 * @param args the command line arguments
 *//*w w w. j  a  v  a 2 s .  c  o  m*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new MainFrame().setVisible(true);
        }
    });
}

From source file:com.awesomecoding.minetestlauncher.Main.java

private void initialize() {
    fileGetter = new FileGetter(userhome + "\\minetest\\temp\\");
    latest = fileGetter.getContents("http://socialmelder.com/minetest/latest.txt", true);
    currentVersion = latest.split("\n")[0];
    changelog = fileGetter.getContents("http://socialmelder.com/minetest/changelog.html", false);

    try {/*w w  w.jav  a2  s.  c o  m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        e.printStackTrace();
    }

    frmMinetestLauncherV = new JFrame();
    frmMinetestLauncherV.setResizable(false);
    frmMinetestLauncherV.setIconImage(Toolkit.getDefaultToolkit()
            .getImage(Main.class.getResource("/com/awesomecoding/minetestlauncher/icon.png")));
    frmMinetestLauncherV.setTitle("Minetest Launcher (Version 0.1)");
    frmMinetestLauncherV.setBounds(100, 100, 720, 480);
    frmMinetestLauncherV.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    SpringLayout springLayout = new SpringLayout();
    frmMinetestLauncherV.getContentPane().setLayout(springLayout);

    final JProgressBar progressBar = new JProgressBar();
    springLayout.putConstraint(SpringLayout.WEST, progressBar, 10, SpringLayout.WEST,
            frmMinetestLauncherV.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, progressBar, -10, SpringLayout.SOUTH,
            frmMinetestLauncherV.getContentPane());
    springLayout.putConstraint(SpringLayout.EAST, progressBar, -130, SpringLayout.EAST,
            frmMinetestLauncherV.getContentPane());
    frmMinetestLauncherV.getContentPane().add(progressBar);

    final JButton btnDownloadPlay = new JButton("Play!");
    springLayout.putConstraint(SpringLayout.WEST, btnDownloadPlay, 6, SpringLayout.EAST, progressBar);
    springLayout.putConstraint(SpringLayout.SOUTH, btnDownloadPlay, 0, SpringLayout.SOUTH, progressBar);
    springLayout.putConstraint(SpringLayout.EAST, btnDownloadPlay, -10, SpringLayout.EAST,
            frmMinetestLauncherV.getContentPane());
    frmMinetestLauncherV.getContentPane().add(btnDownloadPlay);

    final JLabel label = new JLabel("Ready to play!");
    springLayout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST,
            frmMinetestLauncherV.getContentPane());
    springLayout.putConstraint(SpringLayout.NORTH, btnDownloadPlay, 0, SpringLayout.NORTH, label);
    springLayout.putConstraint(SpringLayout.SOUTH, label, -37, SpringLayout.SOUTH,
            frmMinetestLauncherV.getContentPane());
    springLayout.putConstraint(SpringLayout.NORTH, progressBar, 6, SpringLayout.SOUTH, label);
    frmMinetestLauncherV.getContentPane().add(label);

    JTextPane txtpnNewFeatures = new JTextPane();
    txtpnNewFeatures.setBackground(SystemColor.window);
    springLayout.putConstraint(SpringLayout.NORTH, txtpnNewFeatures, 10, SpringLayout.NORTH,
            frmMinetestLauncherV.getContentPane());
    springLayout.putConstraint(SpringLayout.WEST, txtpnNewFeatures, 10, SpringLayout.WEST,
            frmMinetestLauncherV.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, txtpnNewFeatures, -10, SpringLayout.NORTH, btnDownloadPlay);
    springLayout.putConstraint(SpringLayout.EAST, txtpnNewFeatures, 0, SpringLayout.EAST, btnDownloadPlay);
    txtpnNewFeatures.setEditable(false);
    txtpnNewFeatures.setContentType("text/html");
    txtpnNewFeatures.setText(changelog);
    txtpnNewFeatures.setFont(new Font("Tahoma", Font.PLAIN, 12));
    frmMinetestLauncherV.getContentPane().add(txtpnNewFeatures);

    File file = new File(userhome + "\\minetest\\version.txt");

    if (!file.exists())
        newVersion = true;
    else {
        String version = fileGetter.getLocalContents(file, false);
        if (!version.equals(currentVersion))
            newVersion = true;
    }

    if (newVersion) {
        label.setText("New Version Available! (" + currentVersion + ")");
        btnDownloadPlay.setText("Download & Play");

        btnDownloadPlay.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent arg0) {
                Thread t = new Thread() {
                    public void run() {
                        File file = new File(userhome + "\\minetest\\version.txt");
                        String version = fileGetter.getLocalContents(file, false);
                        try {
                            FileUtils.deleteDirectory(new File(userhome + "\\minetest\\minetest-" + version));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        fileGetter.download(latest.split("\n")[1], userhome + "\\minetest\\temp\\",
                                "minetest.zip", label, progressBar, btnDownloadPlay, currentVersion);
                        try {
                            label.setText("Cleaning up...");
                            btnDownloadPlay.setText("Cleaning up...");
                            FileUtils.deleteDirectory(new File(userhome + "\\minetest\\temp"));
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        System.exit(0);
                    }
                };
                t.start();
            }
        });
    } else {
        btnDownloadPlay.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent arg0) {
                try {
                    label.setText("Launching...");
                    btnDownloadPlay.setEnabled(false);
                    btnDownloadPlay.setText("Launching...");
                    File file = new File(userhome + "\\minetest\\version.txt");
                    String version = fileGetter.getLocalContents(file, false);
                    Runtime.getRuntime()
                            .exec(userhome + "\\minetest\\minetest-" + version + "\\bin\\minetest.exe");
                    System.exit(0);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        progressBar.setValue(100);
    }
}