List of usage examples for javax.swing LookAndFeel getName
public abstract String getName();
From source file:es.darkhogg.hazelnutt.Hazelnutt.java
/** * Runs the application//from ww w .j a va2s. c o m * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // Print some version information LOGGER.log(Level.OFF, "----------------"); LOGGER.info("Hazelnutt " + VERSION); LOGGER.trace("Selecting Look&Feel..."); // Select the L&F from configuration or the default if not present String slaf = CONFIG.getString("Hazelnutt.gui.lookAndFeel"); if (slaf == null) { LOGGER.info("Configuration entry for L&F missing, creating default"); slaf = UIManager.getSystemLookAndFeelClassName(); } // Set it or print an error try { UIManager.setLookAndFeel(slaf); } catch (Exception e) { LOGGER.warn("Error while selecting the L&F \"" + slaf + "\", leaving default"); } // Update the configuration with the currently selected L&F LookAndFeel laf = UIManager.getLookAndFeel(); LOGGER.debug("L&F selected: " + laf.getName() + " (" + laf.getClass().getName() + ")"); CONFIG.setProperty("Hazelnutt.gui.lookAndFeel", laf.getClass().getName()); // Load the frame LOGGER.trace("Launching main frame..."); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SwingUtilities.updateComponentTreeUI(FRAME); FRAME.setVisible(true); } }); }
From source file:com.commander4j.util.JUtility.java
public static void adjustForLookandFeel() { LookAndFeel lf = UIManager.getLookAndFeel(); if (lf.getName().equals("Mac OS X")) { Common.LFAdjustWidth = 0;/*from www . j ava 2 s . co m*/ Common.LFAdjustHeight = 0; Common.LFTreeMenuAdjustWidth = 13; Common.LFTreeMenuAdjustHeight = 13; System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Commander4j"); } else { Common.LFAdjustWidth = -13; Common.LFAdjustHeight = -13; Common.LFTreeMenuAdjustWidth = 0; Common.LFTreeMenuAdjustHeight = 0; } }
From source file:com.sshtools.common.ui.SshToolsApplication.java
/** * * * @param className/* w w w . j av a 2s.co m*/ * * @throws Exception */ public static void setLookAndFeel(String className) throws Exception { LookAndFeel laf = null; if (!className.equals(DEFAULT_LAF)) { if (className.equals(SYSTEM_LAF)) { String systemLaf = UIManager.getSystemLookAndFeelClassName(); log.debug("System Look And Feel is " + systemLaf); laf = (LookAndFeel) Class.forName(systemLaf).newInstance(); } else if (className.equals(CROSS_PLATFORM_LAF)) { String crossPlatformLaf = UIManager.getCrossPlatformLookAndFeelClassName(); log.debug("Cross Platform Look And Feel is " + crossPlatformLaf); laf = (LookAndFeel) Class.forName(crossPlatformLaf).newInstance(); } else { laf = (LookAndFeel) Class.forName(className).newInstance(); } } // Now actually set the look and feel if (laf != null) { log.info("Setting look and feel " + laf.getName() + " (" + laf.getClass().getName() + ")"); UIManager.setLookAndFeel(laf); UIManager.put("EditorPane.font", UIManager.getFont("TextArea.font")); } }
From source file:DefaultsDisplay.java
protected void addDefaultsTab() { LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); JScrollPane scrollPane = new JScrollPane(createDefaultsTable()); tabPane.addTab(lookAndFeel.getName() + " Defaults", scrollPane); defaultsTablesMap.put(lookAndFeel.getName(), scrollPane); }
From source file:org.mbs3.juniuploader.gui.pnlSettings.java
private void initGUI() { try {/*from ww w.j av a 2s .c om*/ GridBagLayout thisLayout = new GridBagLayout(); thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 }; thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 }; thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 }; this.setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(659, 349)); { { grpMain = new ButtonGroup(); } { grpGUI = new ButtonGroup(); } { grpObjects = new ButtonGroup(); } { grpHTTP = new ButtonGroup(); } { } { } lblGUI = new JLabel(); this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblGUI.setText("Graphical Interface"); } { lblMain = new JLabel(); this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblMain.setText("Main Program"); } { lblObj = new JLabel(); this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblObj.setText("Object Messages"); } { lblLObj = new JLabel(); this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblLObj.setText("HTTP Messages"); } { lblFatal = new JLabel(); this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblFatal.setText("Fatal Messages"); } { lblError = new JLabel(); this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblError.setText("Errors"); } { lblWarn = new JLabel(); this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblWarn.setText("Warnings"); } { lblInfo = new JLabel(); this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblInfo.setText("Info Messages"); } { lblDebug = new JLabel(); this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblDebug.setText("Debug Messages"); } { lblTrace = new JLabel(); this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); lblTrace.setText("Trace Execution"); } { btnMainFatal = new JRadioButton(); this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } grpMain.add(btnMainFatal); btnMainFatal.setActionCommand("fatal"); btnMainFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); { btnMainError = new JRadioButton(); this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainError); btnMainError.setActionCommand("error"); btnMainError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainWarn = new JRadioButton(); this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainWarn); btnMainWarn.setActionCommand("warn"); btnMainWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainInfo = new JRadioButton(); this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainInfo); btnMainInfo.setActionCommand("info"); btnMainInfo.setSelected(true); btnMainInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainDebug = new JRadioButton(); this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainDebug); btnMainDebug.setActionCommand("debug"); btnMainDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnMainTrace = new JRadioButton(); this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpMain.add(btnMainTrace); btnMainTrace.setActionCommand("trace"); btnMainTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIFatal = new JRadioButton(); this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIFatal); btnGUIFatal.setActionCommand("fatal"); btnGUIFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIError = new JRadioButton(); this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIError); btnGUIError.setActionCommand("error"); btnGUIError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIWarn = new JRadioButton(); this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIWarn); btnGUIWarn.setActionCommand("warn"); btnGUIWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIInfo = new JRadioButton(); this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIInfo); btnGUIInfo.setActionCommand("info"); btnGUIInfo.setSelected(true); btnGUIInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUIDebug = new JRadioButton(); this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUIDebug); btnGUIDebug.setActionCommand("debug"); btnGUIDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnGUITrace = new JRadioButton(); this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpGUI.add(btnGUITrace); btnGUITrace.setActionCommand("trace"); btnGUITrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjFatal = new JRadioButton(); this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjFatal); btnObjFatal.setActionCommand("fatal"); btnObjFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjError = new JRadioButton(); this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjError); btnObjError.setActionCommand("error"); btnObjError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjWarn = new JRadioButton(); this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjWarn); btnObjWarn.setActionCommand("warn"); btnObjWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjInfo = new JRadioButton(); this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjInfo); btnObjInfo.setActionCommand("info"); btnObjInfo.setSelected(true); btnObjInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjDebug = new JRadioButton(); this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjDebug); btnObjDebug.setActionCommand("debug"); btnObjDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnObjTrace = new JRadioButton(); this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpObjects.add(btnObjTrace); btnObjTrace.setActionCommand("trace"); btnObjTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPFatal = new JRadioButton(); this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPFatal); btnHTTPFatal.setActionCommand("fatal"); btnHTTPFatal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPError = new JRadioButton(); this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPError); btnHTTPError.setActionCommand("error"); btnHTTPError.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPWarn = new JRadioButton(); this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPWarn); btnHTTPWarn.setActionCommand("warn"); btnHTTPWarn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPInfo = new JRadioButton(); this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPInfo); btnHTTPInfo.setActionCommand("info"); btnHTTPInfo.setSelected(true); btnHTTPInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPDebug = new JRadioButton(); this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPDebug); btnHTTPDebug.setActionCommand("debug"); btnHTTPDebug.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { btnHTTPTrace = new JRadioButton(); this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); grpHTTP.add(btnHTTPTrace); btnHTTPTrace.setActionCommand("trace"); btnHTTPTrace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { logLevelBtnAction(evt); } }); } { lblLogLevel = new JLabel(); this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblLogLevel.setText("Set the level of logging for different parts of this application:"); } { lblDeLF = new JLabel(); this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblDeLF.setText("Set the look and feel for the GUI of this application:"); } { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); LookAndFeel lf = UIManager.getLookAndFeel(); DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel(); for (int i = 0; i < lfs.length; i++) { String n = lfs[i].getName(); cmbLFModel.addElement(n); if (lf.getName().equals(lfs[i].getName())) cmbLFModel.setSelectedItem(n); } cmbLF = new JComboBox(); this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); cmbLF.setModel(cmbLFModel); cmbLF.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { cmbLFItemStateChanged(evt); } }); } { tfUserAgent = new JTextField(Util.getUserAgent()); this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); tfUserAgent.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent evt) { tfUserAgentKeyReleased(evt); } }); } { lblUserAgent = new JLabel(); this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); lblUserAgent.setText("User Agent"); } { btnExport = new JToggleButton(); this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); btnExport.setText("Export All Settings and Data to File"); btnExport.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnExportActionPerformed(evt); } }); } { txtWarn = new JTextPane(); this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); txtWarn.setText( "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run."); txtWarn.setEditable(false); txtWarn.setBackground(new java.awt.Color(255, 255, 255)); txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0))); } } catch (Exception e) { e.printStackTrace(); } }
From source file:org.zaproxy.zap.utils.ZapSupportUtils.java
public static String getLookAndFeel() { LookAndFeel laf = UIManager.getLookAndFeel(); String strLaf;/*from w ww . j av a 2 s . c om*/ if (laf != null) { strLaf = laf.getName() + " (" + laf.getClass().getCanonicalName() + ")"; } else { strLaf = "[null]"; } return Constant.messages.getString("support.laf.label") + " " + strLaf; }
From source file:phex.gui.common.LookAndFeelUtils.java
public static void setLookAndFeel(LookAndFeel laf) throws LookAndFeelFailedException { try {//from w w w . j av a2 s .co m // don't update LAF if already set... if (laf.getID().equals(UIManager.getLookAndFeel().getID())) { return; } UIManager.setLookAndFeel(laf); GUIUtils.updateComponentsUI(); } catch (UnsupportedLookAndFeelException exp) { NLogger.error(LookAndFeelUtils.class, "Instantiation faield: " + laf.getName(), exp); throw new LookAndFeelFailedException("Instantiation faield: " + laf.getName()); } }