Java Code Examples for javax.swing.plaf.basic.BasicLookAndFeel

The following examples show how to use javax.swing.plaf.basic.BasicLookAndFeel. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: material-ui-swing   Source File: MaterialLookAndFeel.java    License: MIT License 6 votes vote down vote up
public static void changeTheme(MaterialTheme theme) {
	if (theme == null) {
		throw new IllegalArgumentException("Theme null");
	}
	BasicLookAndFeel blaf = (BasicLookAndFeel) UIManager.getLookAndFeel();
	if (blaf instanceof MaterialLookAndFeel) {
		MaterialLookAndFeel materialLookAndFeel = (MaterialLookAndFeel) blaf;
		UIManager.removeAuxiliaryLookAndFeel(materialLookAndFeel);
		theme.installTheme();
		materialLookAndFeel.setTheme(theme);
		try {
			UIManager.setLookAndFeel(materialLookAndFeel);
		} catch (UnsupportedLookAndFeelException e) {
			throw new MaterialChangeThemeException("Exception generated when I change the theme\nError exception is: " + e.getLocalizedMessage());
		}
		return;
	}

	throw new MaterialChangeThemeException("The look and feel setted not is MaterialLookAnfFeel");
}
 
Example 2
Source Project: material-ui-swing   Source File: MaterialLookAndFeel.java    License: MIT License 6 votes vote down vote up
@Override
public UIDefaults getDefaults() {
	try {
		final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
		superMethod.setAccessible(true);
		final UIDefaults defaults = (UIDefaults) superMethod.invoke(basicLookAndFeel);
		initClassDefaults(defaults);
		initComponentDefaults(defaults);
		theme.installTheme();
		defaults.put("OptionPane.warningIcon", MaterialImageFactory.getInstance().getImage(MaterialImageFactory.WARNING));
		defaults.put("OptionPane.errorIcon", MaterialImageFactory.getInstance().getImage(MaterialImageFactory.ERROR));
		defaults.put("OptionPane.questionIcon", MaterialImageFactory.getInstance().getImage(MaterialImageFactory.QUESTION));
		defaults.put("OptionPane.informationIcon", MaterialImageFactory.getInstance().getImage(MaterialImageFactory.INFORMATION));
		return defaults;
	} catch (Exception ignore) {
		//do nothing
		ignore.printStackTrace();
	}
	return super.getDefaults();
}
 
Example 3
protected void initComponentDefaults(UIDefaults table) {
  super.initComponentDefaults( table );

  // I'll have to copy some of the resource definitions here, since the
  // original code in BasicLookAndFeel (from which we inherit) uses
  // getClass() to find its resources. That will fail since my
  // classloader does not have these resources.
  //
  // So, the trick is to replace getClass() with MetalLookAndFeel.class

  Object[] defaults = {
    "OptionPane.errorIcon",       LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Error.gif"),
    "OptionPane.informationIcon", LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Inform.gif"),
    "OptionPane.warningIcon",     LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Warn.gif"),
    "OptionPane.questionIcon",    LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Question.gif"),

    "InternalFrame.icon",         LookAndFeel.makeIcon(BasicLookAndFeel.class, "icons/JavaCup.gif"),


    // Button margin slightly smaller than metal to save space
    "Button.margin", new InsetsUIResource(1, 11, 1, 11),


  };
  table.putDefaults(defaults);
}
 
Example 4
Source Project: otroslogviewer   Source File: Appearance.java    License: Apache License 2.0 6 votes vote down vote up
private UIManager.LookAndFeelInfo[] getLookAndFeels() {
  final List<UIManager.LookAndFeelInfo> installed = Arrays
    .stream(UIManager.getInstalledLookAndFeels())
    .filter(ui -> !ui.getName().toLowerCase().matches("cde/motif|metal|windows classic|nimbus"))
    .collect(Collectors.toList());

  final List<BasicLookAndFeel> substance = Arrays.asList(
    new SubstanceBusinessLookAndFeel(),
    new SubstanceGraphiteAquaLookAndFeel()
  );

  final List<UIManager.LookAndFeelInfo> extraLf =
    substance.stream()
      .map(l -> new UIManager.LookAndFeelInfo(l.getName(), l.getClass().getName()))
      .collect(Collectors.toList());
  final ArrayList<UIManager.LookAndFeelInfo> result = new ArrayList<>();
  result.addAll(installed);
  result.addAll(extraLf);
  return result.toArray(new UIManager.LookAndFeelInfo[0]);
}
 
Example 5
Source Project: FlatLaf   Source File: UIDefaultsDump.java    License: Apache License 2.0 5 votes vote down vote up
private void dump( PrintWriter out, Predicate<String> keyFilter ) {
	Class<?> lookAndFeelClass = lookAndFeel instanceof MyBasicLookAndFeel
		? BasicLookAndFeel.class
		: lookAndFeel.getClass();
	out.printf( "Class  %s%n", lookAndFeelClass.getName() );
	out.printf( "ID     %s%n", lookAndFeel.getID() );
	out.printf( "Name   %s%n", lookAndFeel.getName() );
	out.printf( "Java   %s%n", System.getProperty( "java.version" ) );
	out.printf( "OS     %s%n", System.getProperty( "os.name" ) );

	defaults.entrySet().stream()
		.sorted( (key1, key2) -> {
			return String.valueOf( key1 ).compareTo( String.valueOf( key2 ) );
		} )
		.forEach( entry -> {
			Object key = entry.getKey();
			Object value = entry.getValue();

			String strKey = String.valueOf( key );
			if( !keyFilter.test( strKey ) )
				return;

			int dotIndex = strKey.indexOf( '.' );
			String prefix = (dotIndex > 0)
				? strKey.substring( 0, dotIndex )
				: strKey.endsWith( "UI" )
					? strKey.substring( 0, strKey.length() - 2 )
					: "";
			if( !prefix.equals( lastPrefix ) ) {
				lastPrefix = prefix;
				out.printf( "%n%n#---- %s ----%n%n", prefix );
			}

			out.printf( "%-30s ", strKey );
			dumpValue( out, value );
			out.println();
		} );
}
 
Example 6
Source Project: dragonwell8_jdk   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 7
Source Project: TencentKona-8   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 8
Source Project: jdk8u60   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 9
Source Project: openjdk-jdk8u   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 10
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();
        }
    });
}
 
Example 11
Source Project: openjdk-jdk9   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 12
Source Project: jdk8u-jdk   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 13
Source Project: hottub   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 14
Source Project: openjdk-8-source   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 15
Source Project: material-ui-swing   Source File: MaterialLookAndFeel.java    License: MIT License 5 votes vote down vote up
protected void call(String method) {
	try {
		final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
		superMethod.setAccessible(true);
		superMethod.invoke(basicLookAndFeel);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
Example 16
Source Project: openjdk-8   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 17
Source Project: jdk8u_jdk   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 18
Source Project: jdk8u-jdk   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 19
Source Project: jdk8u-dev-jdk   Source File: Test6984643.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example 20
Source Project: Darcula   Source File: DarculaLaf.java    License: Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 21
Source Project: Darcula   Source File: DarculaLaf.java    License: Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 22
Source Project: Darcula   Source File: DarculaLaf.java    License: Apache License 2.0 5 votes vote down vote up
private void call(String method) {
  try {
    final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
    superMethod.setAccessible(true);
    superMethod.invoke(base);
  }
  catch (Exception ignore) {
    log(ignore);
  }
}
 
Example 23
Source Project: Darcula   Source File: DarculaLaf.java    License: Apache License 2.0 5 votes vote down vote up
@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);
  }
}
 
Example 24
Source Project: consulo   Source File: ModernDarkLaf.java    License: Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 25
Source Project: consulo   Source File: ModernDarkLaf.java    License: Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 26
Source Project: consulo   Source File: ModernDarkLaf.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public UIDefaults getDefaultsImpl(UIDefaults superDefaults) {
  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)));
          }
        }
      }
    }

    LafManagerImplUtil.initInputMapDefaults(defaults);
    defaults.put(SupportTextBoxWithExpandActionExtender.class, SupportTextBoxWithExpandActionExtender.INSTANCE);
    defaults.put(SupportTextBoxWithExtensionsExtender.class, SupportTextBoxWithExtensionsExtender.INSTANCE);

    initIdeaDefaults(defaults);
    patchStyledEditorKit(defaults);
    patchComboBox(metalDefaults, defaults);
    defaults.remove("Spinner.arrowButtonBorder");
    defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5));

    MetalLookAndFeel.setCurrentTheme(createMetalTheme());

    defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
    return defaults;
  }
  catch (Exception e) {
    log(e);
  }
  return super.getDefaultsImpl(superDefaults);
}
 
Example 27
Source Project: consulo   Source File: ModernDarkLaf.java    License: Apache License 2.0 5 votes vote down vote up
private void call(String method) {
  try {
    final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
    superMethod.setAccessible(true);
    superMethod.invoke(base);
  }
  catch (Exception ignore) {
    log(ignore);
  }
}
 
Example 28
Source Project: consulo   Source File: ModernDarkLaf.java    License: Apache License 2.0 5 votes vote down vote up
@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);
  }
}
 
Example 29
Source Project: consulo   Source File: BegMenuItemUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 30
Source Project: consulo   Source File: DarculaLaf.java    License: Apache License 2.0 5 votes vote down vote up
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);
  }
}