private static void applySystemFonts(UIDefaults defaults) { try { String fqn = UIManager.getSystemLookAndFeelClassName(); Object systemLookAndFeel = Class.forName(fqn).newInstance(); final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults systemDefaults = (UIDefaults)superMethod.invoke(systemLookAndFeel); for (Map.Entry<Object, Object> entry : systemDefaults.entrySet()) { if (entry.getValue() instanceof Font) { defaults.put(entry.getKey(), entry.getValue()); } } } catch (Exception e) { log(e); } }
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new BasicLookAndFeel() { public String getName() { return "A name"; } public String getID() { return "An id"; } public String getDescription() { return "A description"; } public boolean isNativeLookAndFeel() { return false; } public boolean isSupportedLookAndFeel() { return true; } }); SwingUtilities.invokeLater(new Runnable() { public void run() { new JFileChooser(); } }); }
/** Copied from BasicMenuItemUI */ private void doClick(MenuSelectionManager msm,MouseEvent e) { // Auditory cue if(!isInternalFrameSystemMenu()){ @NonNls ActionMap map=menuItem.getActionMap(); if(map!=null){ Action audioAction=map.get(getPropertyPrefix()+".commandSound"); if(audioAction!=null){ // pass off firing the Action to a utility method BasicLookAndFeel lf=(BasicLookAndFeel)UIManager.getLookAndFeel(); // It's a hack. The method BasicLookAndFeel.playSound has protected access, so // it's imposible to mormally invoke it. try { Method playSoundMethod=BasicLookAndFeel.class.getDeclaredMethod(PLAY_SOUND_METHOD,new Class[]{Action.class}); playSoundMethod.setAccessible(true); playSoundMethod.invoke(lf,new Object[]{audioAction}); } catch(Exception ignored) {} } } } // Visual feedback if(msm==null){ msm=MenuSelectionManager.defaultManager(); } msm.clearSelectedPath(); ((ActionMenuItem)menuItem).fireActionPerformed( new ActionEvent( menuItem, ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers() ) ); }
public DarculaLaf() { try { if (SystemInfo.isWindows || SystemInfo.isLinux) { base = new IdeaLaf(); } else { final String name = UIManager.getSystemLookAndFeelClassName(); base = (BasicLookAndFeel)Class.forName(name).newInstance(); } } catch (Exception e) { log(e); } }
private void callInit(String method, UIDefaults defaults) { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method, UIDefaults.class); superMethod.setAccessible(true); superMethod.invoke(base, defaults); } catch (Exception e) { log(e); } }
private void call(String method) { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method); superMethod.setAccessible(true); superMethod.invoke(base); } catch (Exception ignore) { log(ignore); } }
@Override protected void loadSystemColors(UIDefaults defaults, String[] systemColors, boolean useNative) { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("loadSystemColors", UIDefaults.class, String[].class, boolean.class); superMethod.setAccessible(true); superMethod.invoke(base, defaults, systemColors, useNative); } catch (Exception ignore) { log(ignore); } }
private void setBasicLF() { try { UIManager.setLookAndFeel(new BasicLookAndFeel() { private static final long serialVersionUID = 1L; @Override public boolean isNativeLookAndFeel() { return true; } @Override public boolean isSupportedLookAndFeel() { return true; } @Override public String getDescription() { return null; } @Override public String getID() { return null; } @Override public String getName() { return null; } }); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } }
@Override public UIDefaults getDefaults() { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel()); final UIDefaults defaults = (UIDefaults)superMethod.invoke(base); if (SystemInfo.isLinux) { Font font = findFont("DejaVu Sans"); if (font != null) { for (Object key : defaults.keySet()) { if (key instanceof String && ((String)key).endsWith(".font")) { defaults.put(key, new FontUIResource(font.deriveFont(13f))); } } } } LafManagerImpl.initInputMapDefaults(defaults); initIdeaDefaults(defaults); patchStyledEditorKit(); patchComboBox(metalDefaults, defaults); defaults.remove("Spinner.arrowButtonBorder"); defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5)); MetalLookAndFeel.setCurrentTheme(new DarculaMetalTheme()); if (SystemInfo.isWindows) { //JFrame.setDefaultLookAndFeelDecorated(true); } return defaults; } catch (Exception e) { log(e); } return super.getDefaults(); }
public DarculaLaf() { try { if (SystemInfo.isWindows || SystemInfo.isLinux) { base = new MetalLookAndFeel(); MetalLookAndFeel.setCurrentTheme(new DarculaMetalTheme()); } else { final String name = UIManager.getSystemLookAndFeelClassName(); base = (BasicLookAndFeel)Class.forName(name).newInstance(); } } catch (Exception ignore) { log(ignore); } }
private void callInit(String method, UIDefaults defaults) { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method, UIDefaults.class); superMethod.setAccessible(true); superMethod.invoke(base, defaults); } catch (Exception ignore) { log(ignore); } }
@Override public UIDefaults getDefaults() { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel()); final UIDefaults defaults = (UIDefaults)superMethod.invoke(base); initInputMapDefaults(defaults); initIdeaDefaults(defaults); patchStyledEditorKit(); patchComboBox(metalDefaults, defaults); defaults.remove("Spinner.arrowButtonBorder"); defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5)); defaults.put("Tree.collapsedIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/treeNodeCollapsed.png"))); defaults.put("Tree.expandedIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/treeNodeExpanded.png"))); defaults.put("Menu.arrowIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/menuItemArrowIcon.png"))); defaults.put("CheckBoxMenuItem.checkIcon", EmptyIcon.create(16)); defaults.put("RadioButtonMenuItem.checkIcon", EmptyIcon.create(16)); defaults.put("InternalFrame.icon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/internalFrame.png"))); defaults.put("OptionPane.informationIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/option_pane_info.png"))); defaults.put("OptionPane.questionIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/option_pane_question.png"))); defaults.put("OptionPane.warningIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/option_pane_warning.png"))); defaults.put("OptionPane.errorIcon", new IconUIResource(IconLoader.getIcon("/com/bulenkov/darcula/icons/option_pane_error.png"))); if (SystemInfo.isMac && !"true".equalsIgnoreCase(System.getProperty("apple.laf.useScreenMenuBar", "false"))) { defaults.put("MenuBarUI", "com.bulenkov.darcula.ui.DarculaMenuBarUI"); defaults.put("MenuUI", "javax.swing.plaf.basic.BasicMenuUI"); } return defaults; } catch (Exception ignore) { log(ignore); } return super.getDefaults(); }
public ModernDarkLaf() { try { if (SystemInfo.isWindows || SystemInfo.isLinux) { base = new IntelliJMetalLookAndFeel(); } else { final String name = UIManager.getSystemLookAndFeelClassName(); base = (BasicLookAndFeel)Class.forName(name).newInstance(); } } catch (Exception e) { log(e); } }
@Override public UIDefaults getDefaults() { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel()); final UIDefaults defaults = (UIDefaults)superMethod.invoke(base); if (SystemInfo.isLinux && !Registry.is("darcula.use.native.fonts.on.linux")) { Font font = findFont("DejaVu Sans"); if (font != null) { for (Object key : defaults.keySet()) { if (key instanceof String && ((String)key).endsWith(".font")) { defaults.put(key, new FontUIResource(font.deriveFont(13f))); } } } } LafManagerImpl.initInputMapDefaults(defaults); initIdeaDefaults(defaults); patchStyledEditorKit(defaults); patchComboBox(metalDefaults, defaults); defaults.remove("Spinner.arrowButtonBorder"); defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5)); MetalLookAndFeel.setCurrentTheme(createMetalTheme()); if (SystemInfo.isWindows) { //JFrame.setDefaultLookAndFeelDecorated(true); } defaults.put("EditorPane.font", defaults.getFont("TextField.font")); return defaults; } catch (Exception e) { log(e); } return super.getDefaults(); }
/** * Copied from BasicMenuItemUI */ private void doClick(MenuSelectionManager msm, MouseEvent e) { // Auditory cue if (!isInternalFrameSystemMenu()) { @NonNls ActionMap map = menuItem.getActionMap(); if (map != null) { Action audioAction = map.get(getPropertyPrefix() + ".commandSound"); if (audioAction != null) { // pass off firing the Action to a utility method BasicLookAndFeel lf = (BasicLookAndFeel)UIManager.getLookAndFeel(); // It's a hack. The method BasicLookAndFeel.playSound has protected access, so // it's imposible to mormally invoke it. try { Method playSoundMethod = BasicLookAndFeel.class.getDeclaredMethod(PLAY_SOUND_METHOD, new Class[]{Action.class}); playSoundMethod.setAccessible(true); playSoundMethod.invoke(lf, new Object[]{audioAction}); } catch (Exception ignored) { } } } } // Visual feedback if (msm == null) { msm = MenuSelectionManager.defaultManager(); } msm.clearSelectedPath(); menuItem.doClick(0); }
public DarculaLaf() { try { if (SystemInfo.isWindows || SystemInfo.isLinux) { base = new IntelliJMetalLookAndFeel(); } else { final String name = UIManager.getSystemLookAndFeelClassName(); base = (BasicLookAndFeel)Class.forName(name).newInstance(); } } catch (Exception e) { log(e); } }