List of usage examples for javax.swing UIManager getLookAndFeel
public static LookAndFeel getLookAndFeel()
null
. From source file:org.zaproxy.zap.utils.ZapSupportUtils.java
public static String getLookAndFeel() { LookAndFeel laf = UIManager.getLookAndFeel(); String strLaf;// w w w .j a v a 2s. co m 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.GUIRegistry.java
public String getUsedLAFClass() { return UIManager.getLookAndFeel().getClass().getName(); }
From source file:phex.gui.common.GUIRegistry.java
private void initializeGUISettings(DGuiSettings guiSettings) { // set default values... if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) { showTableHorizontalLines = false; showTableVerticalLines = false;/*from w w w .ja v a 2 s . c o m*/ } else { showTableHorizontalLines = true; showTableVerticalLines = true; } useLogBandwidthSlider = false; showRespectCopyrightNotice = true; // sets old values from old cfg... ToolTipManager.sharedInstance().setEnabled(InterfacePrefs.DisplayTooltip.get().booleanValue()); String userLafClass; String iconPackName; // load values from gui new settings if available. if (guiSettings != null) { if (guiSettings.isSetLogBandwidthSliderUsed()) { useLogBandwidthSlider = guiSettings.isLogBandwidthSliderUsed(); } if (guiSettings.isSetShowRespectCopyrightNotice()) { showRespectCopyrightNotice = guiSettings.isShowRespectCopyrightNotice(); } DTableList tableList = guiSettings.getTableList(); if (tableList != null && tableList.isSetShowHorizontalLines()) { showTableHorizontalLines = tableList.isShowHorizontalLines(); } if (tableList != null && tableList.isSetShowVerticalLines()) { showTableVerticalLines = tableList.isShowVerticalLines(); } iconPackName = guiSettings.getIconPackName(); userLafClass = guiSettings.getLookAndFeelClass(); } else { userLafClass = null; iconPackName = null; } if (iconPackName != null) { plafIconPack = IconPack.createIconPack(iconPackName); } if (plafIconPack == null) { plafIconPack = IconPack.createDefaultIconPack(); } LookAndFeel laf = LookAndFeelUtils.determineLAF(userLafClass); String phexLafClass = laf.getClass().getName(); if (userLafClass != null && !phexLafClass.equals(userLafClass)) {// in case we had to switch LAF show error. JOptionPane.showMessageDialog(GUIRegistry.getInstance().getMainFrame(), Localizer.getString("LAF_ErrorLoadingSwitchToDefault"), Localizer.getString("Error"), JOptionPane.ERROR_MESSAGE); } if (phexLafClass.equals(UIManager.getLookAndFeel().getClass().getName())) { // in case correct laf is already set just update UI! // this must be done to get colors correctly initialized! GUIUtils.updateComponentsUI(); } else { try { LookAndFeelUtils.setLookAndFeel(laf); } catch (ExceptionInInitializerError ex) { // headless mode } catch (LookAndFeelFailedException e) {// this is supposed to never happen.. since the LAF // should already be tested to function. assert (false); } } }
From source file:phex.gui.common.LookAndFeelUtils.java
public static void setCurrentTheme(String lafClassName, Object theme) { if (lafClassName.equals(Options.PLASTICXP_NAME)) { PlasticLookAndFeel.setPlasticTheme((PlasticTheme) theme); try {/* www . j a va 2 s. co m*/ // after setting the theme we must reset the PlasticLAF UIManager.setLookAndFeel(UIManager.getLookAndFeel()); } catch (UnsupportedLookAndFeelException exp) {// this is not expected to happen since we reset a existing LAF NLogger.error(LookAndFeelUtils.class, exp, exp); } } GUIUtils.updateComponentsUI(); }
From source file:phex.gui.common.LookAndFeelUtils.java
public static void setLookAndFeel(LookAndFeel laf) throws LookAndFeelFailedException { try {/*from w w w .j a v a2s.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()); } }
From source file:phex.gui.common.PhexColors.java
/** * Colors get usually update when a UI update is performed. *//*from www .j a va2s. c om*/ public static void updateColors() { Color activeCaptionBorderColor = UIManager.getColor("activeCaptionBorder"); Color infoColor = UIManager.getColor("info"); if ((SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) && UIManager.getLookAndFeel().isNativeLookAndFeel()) { // in case this is native LAF we use our special orange color set // this is done because the standard ui colors we use for other LAF // just look so bad and ugly on Mac OSX. activatePhexColors(); } else if (infoColor == null || activeCaptionBorderColor == null) { // to prevent errors on LAF with some missing UI Colors we use // the Phex color set on this LAF. // (occures on Linux with GTK LAF) activatePhexColors(); } else { boxPanelBorderColor = GUIUtils.darkerColor(activeCaptionBorderColor, 0.8); boxPanelBackground = new Color(infoColor.getRGB()); boxHeaderBackground = GUIUtils.darkerColor(activeCaptionBorderColor, 0.9); boxHeaderGradientFrom = new Color(activeCaptionBorderColor.getRGB()); boxHeaderGradientTo = GUIUtils.brighterColor(infoColor, 0.8); linkLabelRolloverForeground = GUIUtils.darkerColor(activeCaptionBorderColor, 0.8); scopeProgressBarBackground = UIManager.getColor("window"); scopeProgressBarForeground = UIManager.getColor("ProgressBar.foreground"); finishedScopeProgressBarForeground = scopeProgressBarForeground; // give it a touch of red and saturation unverifiedScopeProgressBarForeground = new Color(0xf04656); // use a lighter color blockedScopeProgressBarForeground = GUIUtils.brighterColor(infoColor, 0.7); } }
From source file:shuffle.fwk.ShuffleController.java
/** * Creates a ShuffleController with the given configuration paths for the primary configuration * (which tells other managers where to get their configurations). If there are none passed, then * "config/main.txt" is assumed.// w w w .j a va 2 s . c o m * * @param configPaths * The paths as Strings */ public ShuffleController(String... configPaths) { if (configPaths.length > 0 && configPaths[0] != null) { factory = new ConfigFactory(configPaths[0]); } else { factory = new ConfigFactory(); } Integer menuFontOverride = getPreferencesManager().getIntegerValue(KEY_FONT_SIZE_SCALING); if (menuFontOverride != null && menuFontOverride != 100 && menuFontOverride >= 1 && menuFontOverride <= 10000) { float scale = menuFontOverride.floatValue() / 100.0f; try { // This is the cleanest and most bug-free way to do this hack. Set<Object> allKeys = new HashSet<Object>(); allKeys.add("JMenu.font"); // Yes we're not supposed to use this, but it is the only one that works with Nimbus LAF allKeys.addAll(UIManager.getLookAndFeelDefaults().keySet()); Object value = UIManager.get("defaultFont"); if (value != null && value instanceof FontUIResource) { FontUIResource fromFont = (javax.swing.plaf.FontUIResource) value; FontUIResource toFont = new FontUIResource(fromFont.deriveFont(fromFont.getSize() * scale)); // This one is necessary UIManager.getLookAndFeel().getDefaults().put("defaultFont", toFont); // And this one allows other LAF to be used in the future UIManager.getDefaults().put("defaultFont", toFont); } // Needed for Nimbus's JTable row height adjustment Object tableFontValue = UIManager.getLookAndFeel().getDefaults().get("Table.font"); Number bestRowHeight = null; if (tableFontValue != null && tableFontValue instanceof FontUIResource) { FontUIResource fromFont = (FontUIResource) tableFontValue; bestRowHeight = fromFont.getSize(); } Object rowHeightValue = UIManager.getLookAndFeel().getDefaults().get("Table.rowHeight"); if (rowHeightValue != null && rowHeightValue instanceof Number) { Number rowHeight = (Number) rowHeightValue; rowHeight = rowHeight.doubleValue() * scale; if (bestRowHeight == null || bestRowHeight.intValue() < rowHeight.intValue()) { bestRowHeight = rowHeight; } } if (bestRowHeight != null) { bestRowHeight = bestRowHeight.doubleValue() * (4.0 / 3.0); } if (bestRowHeight != null && bestRowHeight.intValue() > 0) { UIManager.getLookAndFeel().getDefaults().put("Table.rowHeight", bestRowHeight.intValue()); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOG.log(Level.SEVERE, "Cannot override menu font sizes!", e); } } try { setModel(new ShuffleModel(this)); setView(new ShuffleView(this)); getModel().checkLocaleConfig(); loadFrame(); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOG.log(Level.SEVERE, "Failure on start:", e); } }
From source file:unikn.dbis.univis.explorer.VExplorer.java
License:asdf
private void initMenuBar() { JMenuBar menuBar = new JMenuBar(); VMenu program = new VMenu(Constants.PROGRAM); VMenuItem schemaImport = new VMenuItem(Constants.SCHEMA_IMPORT, VIcons.SCHEMA_IMPORT); schemaImport.setAccelerator(KeyStroke.getKeyStroke('I', Event.CTRL_MASK)); schemaImport.addActionListener(new ActionListener() { /**/* w w w . j a v a 2s. com*/ * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.addChoosableFileFilter(new FileFilter() { /** * Whether the given file is accepted by this filter. */ public boolean accept(File f) { return f.getName().endsWith(".vs.xml") || f.isDirectory(); } /** * The description of this filter. For example: "JPG and GIF Images" * * @see javax.swing.filechooser.FileView#getName */ public String getDescription() { return "UniVis Schema (*.vs.xml)"; } }); int option = fileChooser.showOpenDialog(VExplorer.this); if (option == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); new SchemaImport(file); refreshTree(); JOptionPane.showMessageDialog(VExplorer.this, "Schema Import erfolgreich beendet.", "Schema Import", JOptionPane.INFORMATION_MESSAGE); } } }); program.add(schemaImport); program.addSeparator(); VMenuItem exit = new VMenuItem(Constants.EXIT, VIcons.EXIT); exit.setAccelerator(KeyStroke.getKeyStroke('Q', Event.ALT_MASK)); exit.addActionListener(new ActionListener() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { System.exit(0); } }); program.add(exit); VMenu lafMenu = new VMenu(Constants.LOOK_AND_FEEL); ButtonGroup lafGroup = new ButtonGroup(); for (final UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { JRadioButtonMenuItem lafMenuItem = new JRadioButtonMenuItem(laf.getName()); // Set the current Look And Feel as selected. if (UIManager.getLookAndFeel().getName().equals(laf.getName())) { lafMenuItem.setSelected(true); } lafMenuItem.addActionListener(new ActionListener() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { updateLookAndFeel(laf.getClassName()); } }); lafGroup.add(lafMenuItem); lafMenu.add(lafMenuItem); } JMenu questionMark = new JMenu("?"); VMenuItem license = new VMenuItem(Constants.LICENSE); license.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { new LicenseDialog(VExplorer.this); } }); questionMark.add(license); final VMenuItem about = new VMenuItem(Constants.ABOUT, VIcons.INFORMATION); about.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { new AboutPanel(VExplorer.this); } }); questionMark.add(about); menuBar.add(program); menuBar.add(lafMenu); menuBar.add(questionMark); setJMenuBar(menuBar); }