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:edu.harvard.i2b2.query.ui.QueryC.java

/**
 * @param args/*from www.j  ava2s  . com*/
 */
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 1.6.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) {
        queryToolPanel = new QueryToolInvestigatorPanel(this);
    } else {
        queryToolPanel = new QueryToolPanel(this);
    }

    oAwtContainer.add(queryToolPanel);
    queryToolPanel.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:edu.harvard.i2b2.previousquery.QueryC.java

/**
 * @param args//from  w w  w  .j a v a 2 s. c  o  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:forms.frDados.java

/**
 * Instancia o form./*from   ww  w  .  ja  va2s .  c o  m*/
 */
public frDados() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //SwingUtilities.updateComponentTreeUI(this);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException ex) {
        Logger.getLogger(frDados.class.getName()).log(Level.SEVERE, null, ex);
    }

    initComponents();
    this.setLocationRelativeTo(null);

    inicializarTemas();
    initSatGrafico();
    initSatVelox();
    initMapPanel();
    init3DMapPanel();
    carregarListaUsers();
    initOsmPanel();

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

From source file:net.sf.housekeeper.swing.ApplicationPresenter.java

/**
 * Initializes the Look and Feel.//from ww w.ja v a  2  s  . c  o m
 */
private void initLookAndFeel() {

    if (SystemUtils.IS_OS_MAC_OSX) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            //Do nothing if setting the Look and Feel fails.
        }
    } else {
        try {
            UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
        } catch (Exception e) {
            //Do nothing if setting the Look and Feel fails.
        }
    }

    LOG.debug("Using Look and Feel: " + UIManager.getLookAndFeel().getName());
}

From source file:net.sf.jabref.gui.preftabs.AppearancePrefsTab.java

/**
 * Customization of appearance parameters.
 *
 * @param prefs a <code>JabRefPreferences</code> value
 *//*from   w ww  .  j  av a  2 s.  c o m*/
public AppearancePrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;
    setLayout(new BorderLayout());

    // Font sizes:
    fontSize = new JTextField(5);

    // Row padding size:
    rowPadding = new JTextField(5);

    colorCodes = new JCheckBox(Localization.lang("Color codes for required and optional fields"));

    overrideFonts = new JCheckBox(Localization.lang("Override default font settings"));

    showGrid = new JCheckBox(Localization.lang("Show gridlines"));

    FormLayout layout = new FormLayout(
            "1dlu, 8dlu, left:pref, 4dlu, fill:pref, 4dlu, fill:60dlu, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);

    customLAF = new JCheckBox(Localization.lang("Use other look and feel"));
    // Only list L&F which are available
    List<String> lookAndFeels = LookAndFeel.getAvailableLookAndFeels();
    classNamesLAF = new JComboBox<>(lookAndFeels.toArray(new String[lookAndFeels.size()]));
    classNamesLAF.setEditable(true);
    final JComboBox<String> clName = classNamesLAF;
    customLAF.addChangeListener(e -> clName.setEnabled(((JCheckBox) e.getSource()).isSelected()));

    // only the default L&F shows the the OSX specific first dropdownmenu
    if (!OS.OS_X) {
        JPanel pan = new JPanel();
        builder.appendSeparator(Localization.lang("Look and feel"));
        JLabel lab = new JLabel(
                Localization.lang("Default look and feel") + ": " + UIManager.getSystemLookAndFeelClassName());
        builder.nextLine();
        builder.append(pan);
        builder.append(lab);
        builder.nextLine();
        builder.append(pan);
        builder.append(customLAF);
        builder.nextLine();
        builder.append(pan);
        JPanel pan2 = new JPanel();
        lab = new JLabel(Localization.lang("Class name") + ':');
        pan2.add(lab);
        pan2.add(classNamesLAF);
        builder.append(pan2);
        builder.nextLine();
        builder.append(pan);
        lab = new JLabel(Localization
                .lang("Note that you must specify the fully qualified class name for the look and feel,"));
        builder.append(lab);
        builder.nextLine();
        builder.append(pan);
        lab = new JLabel(Localization
                .lang("and the class must be available in your classpath next time you start JabRef."));
        builder.append(lab);
        builder.nextLine();
    }

    builder.leadingColumnOffset(2);
    JLabel lab;
    builder.appendSeparator(Localization.lang("General"));
    JPanel p1 = new JPanel();
    lab = new JLabel(Localization.lang("Menu and label font size") + ":");
    p1.add(lab);
    p1.add(fontSize);
    builder.append(p1);
    builder.nextLine();
    builder.append(overrideFonts);
    builder.nextLine();
    builder.appendSeparator(Localization.lang("Table appearance"));
    JPanel p2 = new JPanel();
    p2.add(new JLabel(Localization.lang("Table row height padding") + ":"));
    p2.add(rowPadding);
    builder.append(p2);
    builder.nextLine();
    builder.append(colorCodes);
    builder.nextLine();
    builder.append(showGrid);
    builder.nextLine();
    JButton fontButton = new JButton(Localization.lang("Set table font"));
    builder.append(fontButton);
    builder.nextLine();
    builder.appendSeparator(Localization.lang("Table and entry editor colors"));
    builder.append(colorPanel);

    JPanel upper = new JPanel();
    JPanel sort = new JPanel();
    JPanel namesp = new JPanel();
    JPanel iconCol = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    upper.setLayout(gbl);
    sort.setLayout(gbl);
    namesp.setLayout(gbl);
    iconCol.setLayout(gbl);

    overrideFonts.addActionListener(e -> fontSize.setEnabled(overrideFonts.isSelected()));

    fontButton.addActionListener(e -> new FontSelectorDialog(null, GUIGlobals.currentFont).getSelectedFont()
            .ifPresent(x -> usedFont = x));

    JPanel pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
}

From source file:Converter.java

private static void initLookAndFeel() {
    String lookAndFeel = null;//from w  w w .j a va 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:com.ethercamp.harmony.desktop.HarmonyDesktop.java

private void showErrorWindow(String title, String body) {
    try {/*  ww  w .  j  ava2s  .c o m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //            System.setProperty("apple.awt.UIElement", "false");

        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        JTextArea textArea = new JTextArea(body);
        JScrollPane scrollPane = new JScrollPane(textArea);
        textArea.setLineWrap(true);
        textArea.setFont(Font.getFont(Font.MONOSPACED));
        textArea.setEditable(false);
        textArea.setWrapStyleWord(true);
        scrollPane.setPreferredSize(new Dimension(500, 500));

        JTextPane titleLabel = new JTextPane();
        titleLabel.setContentType("text/html"); // let the text pane know this is what you want
        titleLabel.setText("<html>" + "<b>" + title + "</b>" + "</html>"); // showing off
        titleLabel.setEditable(false);
        titleLabel.setBackground(null);
        titleLabel.setBorder(null);

        panel.add(titleLabel);
        panel.add(scrollPane);

        final JFrame frame = new JFrame();
        frame.setAlwaysOnTop(true);
        moveCenter(frame);
        frame.setVisible(true);

        JOptionPane.showMessageDialog(frame, panel, "Oops. Ethereum Harmony stopped with error.",
                JOptionPane.CLOSED_OPTION);
        System.exit(1);
    } catch (Exception e) {
        log.error("Problem showing error window", e);
    }
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

public MainController() {
    iliasProperties = readProperties();//from  w w w  .j a  va 2s .  c  o m

    if (iliasProperties.getLookAndFeel() == null || iliasProperties.getLookAndFeel().trim().isEmpty()) {
        iliasProperties.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }

    try {
        UIManager.setLookAndFeel(iliasProperties.getLookAndFeel());
    } catch (Exception e1) {
        e1.printStackTrace();
    }

    fileObjectTableModel = new FileObjectTableModel();
    mainFrame = new MainFrame(this, initMenuBar());

    //      initTableFiles();
    handleFirstStart();

    mainFrame.getFieldLogin().setText(iliasProperties.getUserName());
    updateTitleCaption();
    mainFrame.getCheckboxNotDownload().setSelected(!iliasProperties.isAllowDownload());

    if (!mainFrame.getFieldLogin().getText().trim().isEmpty()) {
        mainFrame.getFieldPassword().requestFocus();
    }

    syncService = new SyncService(this, this, new ObjectDoInterfaceX<Void, IliasProperties>() {//IliasProperties Callback

        @Override
        public IliasProperties doSomething(Void object) {
            iliasProperties.setUserName(mainFrame.getFieldLogin().getText());
            iliasProperties.setAllowDownload(!mainFrame.getCheckboxNotDownload().isSelected());
            saveProperties(iliasProperties);
            return iliasProperties;
        }
    }, new ObjectDoInterfaceX<Void, String>() {//Password Callback

        @Override
        public String doSomething(Void object) {
            return new String(mainFrame.getFieldPassword().getPassword());
        }
    }, new ObjectDoInterfaceX<Throwable, Void>() {

        @Override
        public Void doSomething(Throwable e) {
            showError("Fehler bei der Dateisynchronisierung: " + e.getMessage(), e);
            return null;
        }
    });

    mainFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowIconified(WindowEvent e) {
            minimizeToTray();
        }

        @Override
        public void windowClosing(WindowEvent e) {
            try {
                syncService.logoutIfLoggedIn();
            } catch (Exception ex) {
                System.exit(0);
            }
        }
    });

    startOrStopAutoSync();
}

From source file:net.chaosserver.timelord.swingui.Timelord.java

/**
 * Constructs the new timelord object.//from  www.  jav a2  s  .co  m
 */
public Timelord() {
    // Set the UI to the system look and feel so the application
    // appears more native.
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        if (log.isWarnEnabled()) {
            log.warn("Failed to set look and feel", e);
        }
    }
}

From source file:eu.irreality.age.SwingAetheriaGameLoaderInterface.java

public static void setLookAndFeel() {
    try {/*  w  w  w . ja v  a  2 s.  c o  m*/

        boolean setLAF = true;

        setLAF = false; //pasamos del native look and feel.

        //check java version and native look and feel: seems that GTK look and feel is broken for versions < 1.6

        if (UIManager.getSystemLookAndFeelClassName().indexOf("gtk") >= 0) {
            String javaVersion = System.getProperty("java.version");
            StringTokenizer st = new StringTokenizer(javaVersion, ".-_");
            int firstNum;
            int secondNum;
            try {
                firstNum = Integer.valueOf(st.nextToken()).intValue();
                secondNum = Integer.valueOf(st.nextToken()).intValue();

                /*
                if ( firstNum <= 1 && secondNum <= 5 )
                   setLAF = false;
                */
                //don't use GTK l&f at all
                setLAF = false;
            } catch (Exception exc) {
                ; //version unreadable: bah, set the look and feel and pray.
            }

        }

        if (setLAF) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }

    } catch (Exception ulafe) {
        ulafe.printStackTrace();
    }
}