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

/**
 * @param args the command line arguments
 *//* ww  w  .  ja  v  a2  s  . co 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 {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Good_GUi.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }
    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new Good_GUi().setVisible(true);
        }
    });
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LaunchDiagnosticTool.java

@Override
public void run(CommandLine commandLine) throws Exception {
    SwingUtilities.invokeLater(new Runnable() {

        @Override//from   w  w w  .ja  v a  2s  .  c  o m
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
                //silently handle
            }

            DiagnosticTool diagnosticTool = new DiagnosticTool();
            diagnosticTool.setIconImages(Settings.getIconImages());
            diagnosticTool.setVisible(true);
        }

    });
}

From source file:MainClass.java

public MainClass() {
    theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    cp = theFrame.getContentPane();/*from w  w  w .  j ava  2 s  . c  o m*/
    cp.setLayout(new FlowLayout());

    ButtonGroup bg = new ButtonGroup();

    JRadioButton bJava = new JRadioButton("Java");
    bJava.addActionListener(new LNFSetter("javax.swing.plaf.metal.MetalLookAndFeel", bJava));
    bg.add(bJava);
    cp.add(bJava);

    JRadioButton bMSW = new JRadioButton("MS-Windows");
    bMSW.addActionListener(new LNFSetter("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", bMSW));
    bg.add(bMSW);
    cp.add(bMSW);

    JRadioButton bMotif = new JRadioButton("Motif");
    bMotif.addActionListener(new LNFSetter("com.sun.java.swing.plaf.motif.MotifLookAndFeel", bMotif));
    bg.add(bMotif);
    cp.add(bMotif);

    JRadioButton bMac = new JRadioButton("Sun-MacOS");
    bMac.addActionListener(new LNFSetter("com.sun.java.swing.plaf.mac.MacLookAndFeel", bMac));
    bg.add(bMac);
    cp.add(bMac);

    String defaultLookAndFeel = UIManager.getSystemLookAndFeelClassName();
    JRadioButton bDefault = new JRadioButton("Default");
    bDefault.addActionListener(new LNFSetter(defaultLookAndFeel, bDefault));
    bg.add(bDefault);
    cp.add(bDefault);

    (previousButton = bDefault).setSelected(true);

    theFrame.pack();
    theFrame.setVisible(true);
}

From source file:cl.almejo.vsim.Main.java

private void setNativeLookAndFeel() {
    try {//from   w ww.j ava 2 s  .c  o  m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        GTKHelper.installGtkPopupBugWorkaround();
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:hr.fer.zemris.vhdllab.platform.support.OSBasedUIManagerConfigurer.java

@Override
protected void doInstallCustomDefaults() throws Exception {
    if (System.getProperty("os.name").equals("Linux")) {
        try {/*  w w w  . ja  v  a 2  s  . c om*/
            installJGoodiesLooks();
        } catch (UnsupportedLookAndFeelException e) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            UIManager.put("swing.boldMetal", Boolean.FALSE);
        }
    } else {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
}

From source file:edu.uchc.octane.OctanePlugin.java

/**
 * Constructor//ww  w. j  av a2s .c o m
 */
public OctanePlugin() {
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    } catch (Exception e) {

        System.err.println(e.getMessage());

    }
}

From source file:de.daibutsu.main.MainStart.java

public void run() {
    System.getProperties().setProperty("sun.awt.exception.handler", ExceptionHandler.class.getName());
    try {//www  .j a va  2  s .c  om
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        throw new RuntimeException("Error!", e);
    }

    starteAnwendung();
}

From source file:jshm.gui.GuiUtil.java

/**
 * This sets the default L&F as well as sets some icons
 *///ww w. j  av a 2 s. c  o  m
public static void init() {
    try {
        // Set the Look & Feel to match the current system
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    // http://www.java2s.com/Tutorial/Java/0240__Swing/CustomizingaJOptionPaneLookandFeel.htm
    UIManager.put("OptionPane.errorIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/delete.png")));
    UIManager.put("OptionPane.informationIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/infoabout.png")));
    UIManager.put("OptionPane.questionIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/help.png")));
    UIManager.put("OptionPane.warningIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/pause.png")));
    UIManager.put("OptionPane.yesIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/accept32.png")));
    UIManager.put("OptionPane.noIcon",
            new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/delete32.png")));

    float scale = Config.getFloat("font.scale");

    if (1f != scale) {
        LOG.finest("setting ui font scale to + " + scale);

        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);

            if (value instanceof FontUIResource) {
                FontUIResource f = (FontUIResource) value;
                f = new FontUIResource(f.deriveFont(scale * f.getSize2D()));
                UIManager.put(key, f);
            }
        }
    }

    // hook into the wizard displayer
    System.setProperty("WizardDisplayer.default", "jshm.gui.wizards.displayer.WizardDisplayerImpl");
}

From source file:com.unicorn.co226.ui.patient.AddStudentForm.java

/**
 * Creates new form AddStudentForm/*from ww  w  .  j a  v  a 2s . co m*/
 */
public AddStudentForm(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(WaitingList.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(WaitingList.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(WaitingList.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(WaitingList.class.getName()).log(Level.SEVERE, null, ex);
    }
    this.parent = parent;
    dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    initComponents();
    setLocationRelativeTo(parent);
    medicalPhotos = new File[] {};
    maskFormatterMap = new HashMap<>();

    try {
        maskFormatterMap.put("ENG", new MaskFormatter("E-##-###"));
        MaskFormatter maskFormatter = new MaskFormatter("A-##-###");
        maskFormatter.setValidCharacters("A");
        maskFormatterMap.put("ART", maskFormatter);
        maskFormatterMap.put("SCI", new MaskFormatter("S-##-###"));
        maskFormatterMap.put("MED", new MaskFormatter("M-##-###"));
        maskFormatterMap.put("AHS", new MaskFormatter("AHS-##-###"));
        maskFormatterMap.put("MGT", new MaskFormatter("MGT-##-###"));
        maskFormatterMap.put("VET", new MaskFormatter("V-##-###"));
        maskFormatterMap.put("AGR", new MaskFormatter("AG-##-###"));
        maskFormatterMap.put("DEN", new MaskFormatter("D-##-###"));

    } catch (ParseException ex) {
        Logger.getLogger(AddStudentForm.class.getName()).log(Level.SEVERE, null, ex);
    }
    //dobDatePicker.setDate(new Date(90, 1, 1));
    dobDatePicker.setFormats(dateFormat, new SimpleDateFormat("yyyy"), new SimpleDateFormat("yyyy/MM/dd"));

    fileChooser = new JFileChooser();
    fileChooser.setMultiSelectionEnabled(true);
    fileChooser.setFileFilter(new FileNameExtensionFilter("Images", "jpg", "png"));

    try {
        String nextId = IdGen.getNextId("Patient", "id", "P");
        idTextField.setText(nextId);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(AddStudentForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(AddStudentForm.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:OAT.ui.util.UiUtil.java

public static void useCrossPlatformLookAndFeel(Component object) {
    String laf;/*from   ww  w.  j av  a  2  s  . c  o  m*/
    boolean useNative = false;

    if (useNative) {
        laf = UIManager.getSystemLookAndFeelClassName();
    } else {
        laf = UIManager.getCrossPlatformLookAndFeelClassName();
    }

    try {
        UIManager.setLookAndFeel(laf);
        SwingUtilities.updateComponentTreeUI(object);
    } catch (Exception e) {
        System.err.println("Couldn't use the " + laf + "look and feel: " + e);
    }
}