类javax.swing.plaf.basic.BasicLookAndFeel源码实例Demo

下面列出了怎么用javax.swing.plaf.basic.BasicLookAndFeel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: material-ui-swing   文件: MaterialLookAndFeel.java
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");
}
 
源代码2 项目: material-ui-swing   文件: MaterialLookAndFeel.java
@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();
}
 
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);
}
 
源代码4 项目: otroslogviewer   文件: Appearance.java
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]);
}
 
源代码5 项目: FlatLaf   文件: UIDefaultsDump.java
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();
		} );
}
 
源代码6 项目: dragonwell8_jdk   文件: Test6984643.java
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();
        }
    });
}
 
源代码7 项目: TencentKona-8   文件: Test6984643.java
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();
        }
    });
}
 
源代码8 项目: jdk8u60   文件: Test6984643.java
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();
        }
    });
}
 
源代码9 项目: openjdk-jdk8u   文件: Test6984643.java
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();
        }
    });
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: Test6984643.java
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();
        }
    });
}
 
源代码11 项目: openjdk-jdk9   文件: Test6984643.java
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();
        }
    });
}
 
源代码12 项目: jdk8u-jdk   文件: Test6984643.java
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();
        }
    });
}
 
源代码13 项目: hottub   文件: Test6984643.java
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();
        }
    });
}
 
源代码14 项目: openjdk-8-source   文件: Test6984643.java
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();
        }
    });
}
 
源代码15 项目: material-ui-swing   文件: MaterialLookAndFeel.java
protected void call(String method) {
	try {
		final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
		superMethod.setAccessible(true);
		superMethod.invoke(basicLookAndFeel);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
源代码16 项目: openjdk-8   文件: Test6984643.java
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();
        }
    });
}
 
源代码17 项目: jdk8u_jdk   文件: Test6984643.java
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();
        }
    });
}
 
源代码18 项目: jdk8u-jdk   文件: Test6984643.java
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();
        }
    });
}
 
源代码19 项目: jdk8u-dev-jdk   文件: Test6984643.java
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();
        }
    });
}
 
源代码20 项目: Darcula   文件: DarculaLaf.java
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);
  }
}
 
源代码21 项目: Darcula   文件: DarculaLaf.java
@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();
}
 
源代码22 项目: Darcula   文件: DarculaLaf.java
private void call(String method) {
  try {
    final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
    superMethod.setAccessible(true);
    superMethod.invoke(base);
  }
  catch (Exception ignore) {
    log(ignore);
  }
}
 
源代码23 项目: Darcula   文件: DarculaLaf.java
@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);
  }
}
 
源代码24 项目: consulo   文件: ModernDarkLaf.java
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);
  }
}
 
源代码25 项目: consulo   文件: ModernDarkLaf.java
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);
  }
}
 
源代码26 项目: consulo   文件: ModernDarkLaf.java
@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);
}
 
源代码27 项目: consulo   文件: ModernDarkLaf.java
private void call(String method) {
  try {
    final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
    superMethod.setAccessible(true);
    superMethod.invoke(base);
  }
  catch (Exception ignore) {
    log(ignore);
  }
}
 
源代码28 项目: consulo   文件: ModernDarkLaf.java
@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);
  }
}
 
源代码29 项目: consulo   文件: BegMenuItemUI.java
/**
 * 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);
}
 
源代码30 项目: consulo   文件: DarculaLaf.java
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);
  }
}
 
 类所在包
 同包方法