本文整理汇总了Java中javax.swing.plaf.basic.BasicLookAndFeel类的典型用法代码示例。如果您正苦于以下问题:Java BasicLookAndFeel类的具体用法?Java BasicLookAndFeel怎么用?Java BasicLookAndFeel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicLookAndFeel类属于javax.swing.plaf.basic包,在下文中一共展示了BasicLookAndFeel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applySystemFonts
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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);
}
}
示例2: main
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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();
}
});
}
示例3: doClick
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
/** 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()
)
);
}
示例4: DarculaLaf
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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);
}
}
示例5: callInit
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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);
}
}
示例6: call
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
private void call(String method) {
try {
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod(method);
superMethod.setAccessible(true);
superMethod.invoke(base);
}
catch (Exception ignore) {
log(ignore);
}
}
示例7: loadSystemColors
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
@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);
}
}
示例8: setBasicLF
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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();
}
}
示例9: getDefaults
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
@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();
}
示例10: DarculaLaf
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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);
}
}
示例11: callInit
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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);
}
}
示例12: getDefaults
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
@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();
}
示例13: loadSystemColors
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
@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);
}
}
示例14: ModernDarkLaf
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
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);
}
}
示例15: getDefaults
import javax.swing.plaf.basic.BasicLookAndFeel; //导入依赖的package包/类
@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();
}