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

/** Construct a program... */
public LNFSwitcher() {
    super();//from   ww  w. j a  v  a2 s.c om
    theFrame = new JFrame("LNF Switcher");
    theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    cp = theFrame.getContentPane();
    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();
    // System.out.println(defaultLookAndFeel);
    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:components.Converter.java

private static void initLookAndFeel() {
    String lookAndFeel = null;//w w  w.j  a v a 2  s. c o m

    if (LOOKANDFEEL != null) {
        if (LOOKANDFEEL.equals("Metal")) {
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        } else if (LOOKANDFEEL.equals("System")) {
            lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        } else if (LOOKANDFEEL.equals("Motif")) {
            lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        } else if (LOOKANDFEEL.equals("GTK+")) { //new in 1.4.2
            lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        } else {
            System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL);
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        }

        try {
            UIManager.setLookAndFeel(lookAndFeel);
        } catch (ClassNotFoundException e) {
            System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel);
            System.err.println("Did you include the L&F library in the class path?");
            System.err.println("Using the default look and feel.");
        } catch (UnsupportedLookAndFeelException e) {
            System.err.println("Can't use the specified look and feel (" + lookAndFeel + ") on this platform.");
            System.err.println("Using the default look and feel.");
        } catch (Exception e) {
            System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
            System.err.println("Using the default look and feel.");
            e.printStackTrace();
        }
    }
}

From source file:misc.TablePrintDemo1.java

/**
 * Start the application.//  w ww . j a  v a  2 s . 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 TablePrintDemo1().setVisible(true);
        }
    });
}

From source file:org.pentaho.aggdes.ui.UIMain.java

private void setLAF() {

    try {//from  www .  ja  v  a  2  s  .c  o  m
        String laf = configuration.getLookAndFeel();

        if (laf.equalsIgnoreCase("system")) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else if (laf.equalsIgnoreCase("metal")) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } else if (!StringUtils.isEmpty(laf)) {
            UIManager.setLookAndFeel(laf);
        } else {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }

    } catch (Exception e) {
        logger.warn("error setting look and feel", e); //$NON-NLS-1$
    }

}

From source file:ca.osmcanada.osvuploadr.JPMain.java

/**
 * Creates new form JPMain/*from www  . java  2s . co m*/
 */
public JPMain(Locale locale) {
    l = locale;
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
    }
    initComponents();
    try {
        r = ResourceBundle.getBundle("Bundle", l);
    } catch (Exception ex) {
        System.out.println(ex.toString());
    }

    SetUILang();

}

From source file:com.alvermont.terraj.util.ui.LookAndFeelUtils.java

/**
 * Change the look and feel to either the native one or the cross
 * platform Java one// w w w. ja va2  s.c  om
 *
 * @param wantSystem If <pre>true</pre> then we are selecting the native
 * look and feel
 * @param topLevel The top level component for the main frame
 * @return <pre>true</pre> if the look and feel was successfully changed
 */
public boolean setSystemLookAndFeel(boolean wantSystem, Window topLevel) {
    boolean ok = true;

    try {
        if (wantSystem) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } else {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }

        SwingUtilities.updateComponentTreeUI(topLevel);
        topLevel.pack();

        final LookAndFeelChangedEvent event = new LookAndFeelChangedEvent(this);

        fireLookAndFeelChangedEventListenerHandleLookAndFeelChangedEvent(event);
    } catch (UnsupportedLookAndFeelException ex) {
        log.error("Failed to set LAF", ex);

        ok = false;
    } catch (ClassNotFoundException ex) {
        log.error("Failed to set LAF", ex);

        ok = false;
    } catch (IllegalAccessException ex) {
        log.error("Failed to set LAF", ex);

        ok = false;
    } catch (InstantiationException ex) {
        log.error("Failed to set LAF", ex);

        ok = false;
    }

    return ok;
}

From source file:ch.zhaw.iamp.rct.Controller.java

private void configureGuiToolkit() {
    String operatingSystem = System.getProperty("os.name").toLowerCase();
    boolean isUnix = operatingSystem.contains("nix") || operatingSystem.contains("nux")
            || operatingSystem.contains("aix");

    try {//from  w  w  w. j  ava 2  s  . c  om
        if (isUnix) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        } else {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
    } catch (UnsupportedLookAndFeelException | ClassNotFoundException | IllegalAccessException
            | InstantiationException ex) {
        throw new IllegalStateException("The Look&Feel could not be configured correctly: " + ex.getMessage());
    }
}

From source file:DefaultsDisplay.java

/** Creates a new instance of DefaultsDisplayer */
public DefaultsDisplay() {
    defaultsTablesMap = new HashMap<String, JComponent>();
    try {/*  w  w  w  .  j  a  v a  2 s .c o  m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        if (System.getProperty("os.name").equals("Mac OS X")) {
            OSXLookAndFeelName = UIManager.getLookAndFeel().getName();
        }
    } catch (Exception ex) {
        // better work :-)
    }

    setLayout(new BorderLayout());

    JPanel controls = new JPanel();
    controls.add(createLookAndFeelControl());
    controls.add(createFilterControl());
    add(controls, BorderLayout.NORTH);

    tabPane = new JTabbedPane();
    add(tabPane, BorderLayout.CENTER);

    addDefaultsTab();

}

From source file:edu.harvard.i2b2.query.QueryC.java

/**
 * @param args/* w  w w  .jav a2  s .co m*/
 */
protected Control createContents(Composite parent) {
    //log.info("Starting Query Mode");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    setLayout(topGridLayout);

    Composite queryComposite = new Composite(this, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    // the horizontal sash form
    SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL);
    horizontalForm.setOrientation(SWT.HORIZONTAL);
    horizontalForm.setLayout(new GridLayout());

    //left sash form
    SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    leftVerticalForm.setOrientation(SWT.VERTICAL);
    leftVerticalForm.setLayout(new GridLayout());

    if (bWantStatusLine) {
        slm.createControl(this, SWT.NULL);
    }
    slm.setMessage("i2b2 Explorer Version 2.0");
    slm.update(true);

    // Create the tab folder
    final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    // Create each tab and set its text, tool tip text,
    // image, and control
    TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE);
    oTreeTab.setText("Concept trees");
    oTreeTab.setToolTipText("Hierarchically organized patient characteristics");
    oTreeTab.setControl(getQueryTabControl(oTabFolder));

    //TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE);
    //oFindTab.setText("Find");
    //oFindTab.setToolTipText("Free-form find tool for patient characteristics");
    //FindTool find = new FindTool(slm);

    //oFindTab.setControl(find.getFindTabControl(oTabFolder));

    // Select the first tab (index is zero-based)
    oTabFolder.setSelection(0);

    // Create the tab folder
    final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE);
    previousRunTab.setText("Patient Sets and Previous Queries");
    previousRunTab.setToolTipText("Patient Sets & Previous Queries");
    final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED);
    previousRunTab.setControl(composite);

    /* Create and setting up frame */
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer_left = runRoot.getContentPane();

    //runTreePanel = new QueryPreviousRunsPanel(this, null);
    //oAwtContainer_left.add(runTreePanel);

    // Select the first tab (index is zero-based)
    queryRunFolder.setSelection(0);

    final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    verticalForm.setOrientation(SWT.VERTICAL);
    verticalForm.setLayout(null);

    Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        queryPanel = new QueryPanelInvestigator(this);
    } else {
        queryPanel = new QueryPanel(this);
    }

    oAwtContainer.add(queryPanel);
    queryPanel.setSplitBounds(oAwtContainer.getBounds());

    if (mode_ == 0) {
        //bottomC = new ExplorerC(verticalForm, false);
        verticalForm.setWeights(new int[] { 40, 50 });
    }
    verticalForm.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            if (mode_ == 0) {
                int height = verticalForm.getBounds().height;
                //System.out.println("Height: "+height);
                if (height > 285) {
                    try {
                        verticalForm.setWeights(new int[] { 285, height - 285 });
                    } catch (Exception e) {
                        return;
                    }
                }
            }
        }
    });

    horizontalForm.setWeights(new int[] { 20, 70 });
    return parent;
}

From source file:net.rim.ejde.internal.signing.ImportCSIFilesAction.java

/**
 * Launches the Signature tool. It passes the .csi file to the signature tool.
 *//*from   w w  w .  j a  v a2 s . c  o  m*/
private void launchSignatureTool(String csiFile) {
    log.debug("Entering SignatureToolAction launchSignatureTool()");

    // This is a list of the commands to run. The first position is the
    // actual command; subsequent entries are arguments.
    List<String> commands = new LinkedList<String>();

    // Find the path to java.exe
    String javaHome = System.getProperty("java.home");
    IPath javaBinPath = new Path(javaHome).append(IConstants.BIN_FOLD_NAME).append(IConstants.JAVA_CMD);
    commands.add(javaBinPath.toOSString());

    // Use the system look and feel
    String lookAndFeelClass = UIManager.getSystemLookAndFeelClassName();
    commands.add("-Dswing.defaultlaf=" + lookAndFeelClass);

    // Load from a jar
    commands.add("-jar");

    IPath sigPath;
    String sigPathString = IConstants.EMPTY_STRING;
    try {
        sigPath = VMToolsUtils.getSignatureToolPath();
        // check signature tool again
        if (!VMToolsUtils.isVMToolValid()) {
            Display.getDefault().syncExec(new Runnable() {
                public void run() {
                    Shell shell = ContextManager.getActiveWorkbenchShell();
                    MessageDialog.openError(shell, Messages.ErrorHandler_DIALOG_TITLE,
                            Messages.SignatureTool_Not_Found_Msg);
                }
            });
            log.error(Messages.SignatureTool_Not_Found_Msg);
            return;
        }
        sigPathString = sigPath.toOSString();
        commands.add(sigPathString);
        commands.add(csiFile);

    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }

    // Run the command
    ProcessBuilder processBuilder = new ProcessBuilder(commands);
    try {
        process = processBuilder.start();
        BufferedReader is = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String buffer;
        while ((buffer = is.readLine()) != null) {
            // Print out console output for debugging purposes...
            System.out.println(buffer);
        }
        process = null;
    } catch (IOException e) {
        e.printStackTrace();
    }

    log.debug("Leaving SignatureToolAction launchSignatureTool()");
}