当前位置: 首页>>代码示例>>Java>>正文


Java UIManager.getLookAndFeelDefaults方法代码示例

本文整理汇总了Java中javax.swing.UIManager.getLookAndFeelDefaults方法的典型用法代码示例。如果您正苦于以下问题:Java UIManager.getLookAndFeelDefaults方法的具体用法?Java UIManager.getLookAndFeelDefaults怎么用?Java UIManager.getLookAndFeelDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.UIManager的用法示例。


在下文中一共展示了UIManager.getLookAndFeelDefaults方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaults

import javax.swing.UIManager; //导入方法依赖的package包/类
@Override
public UIDefaults getDefaults() {
	getColors();

	UIDefaults table = new UIDefaults();
	// copy existing default values over
	// enables AntiAliasing if AntiAliasing is enabled in the OS
	// EXCEPT for key "Menu.opaque" which will glitch out JMenues
	UIDefaults lookAndFeelDefaults = UIManager.getLookAndFeelDefaults();
	Hashtable copy = new Hashtable<>(lookAndFeelDefaults);
	for (Object key : copy.keySet()) {
		if (!String.valueOf(key).equals("Menu.opaque")) {
			table.put(key, lookAndFeelDefaults.get(key));
		}
	}

	initClassDefaults(table);
	initSystemColorDefaults(table);
	initComponentDefaults(table);
	COLORS.addCustomEntriesToTable(table);

	return table;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:24,代码来源:RapidLookAndFeel.java

示例2: appSetup

import javax.swing.UIManager; //导入方法依赖的package包/类
/**
 * Do some common setup for all applications at startup
 * @param name the application name used for Java logging and database logging
 */
public static void appSetup(String name)
{
    // Set our platform wide L&F 
    System.setProperty("swing.defaultlaf", "javax.swing.plaf.nimbus.NimbusLookAndFeel");
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    defaults.put("Table.gridColor", new Color(140,140,140));
    defaults.put("Table.showGrid", true);
    
    // Set the program name which is used by PostgresqlDatabase to identify the app in logs
    System.setProperty("program.name", name);
    
    // Start with a fresh root set at warning
    Logger root = LogManager.getLogManager().getLogger("");
    Formatter format = new SingleLineFormatter();

    root.setLevel(Level.WARNING);
    for(Handler handler : root.getHandlers()) {
        root.removeHandler(handler);
    }

    // Set prefs levels before windows preference load barfs useless data on the user
    Logger.getLogger("java.util.prefs").setLevel(Level.SEVERE);
    // postgres JDBC spits out a lot of data even though we catch the exception
    Logger.getLogger("org.postgresql.jdbc").setLevel(Level.OFF);
    Logger.getLogger("org.postgresql.Driver").setLevel(Level.OFF);

    // Add console handler if running in debug mode
    if (Prefs.isDebug()) {
        ConsoleHandler ch = new ConsoleHandler();
        ch.setLevel(Level.ALL);
        ch.setFormatter(format);
        root.addHandler(ch);
    }

    // For our own logs, we can set super fine level or info depending on if debug mode and attach dialogs to those
    Logger applog = Logger.getLogger("org.wwscc");
    applog.setLevel(Prefs.isDebug() ? Level.FINEST : Level.INFO);
    applog.addHandler(new AlertHandler());

    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread t, Throwable e) {
            applog.log(Level.WARNING, String.format("\bUncaughtException in %s: %s", t, e), e);
        }});

    try {
        File logdir = Prefs.getLogDirectory().toFile();
        if (!logdir.exists())
            if (!logdir.mkdirs())
                throw new IOException("Can't create log directory " + logdir);
        FileHandler fh = new FileHandler(new File(logdir, name+".%g.log").getAbsolutePath(), 1000000, 10, true);
        fh.setFormatter(format);
        fh.setLevel(Level.ALL);
        root.addHandler(fh);
    } catch (IOException ioe) {
        JOptionPane.showMessageDialog(FocusManager.getCurrentManager().getActiveWindow(),
                "Unable to enable logging to file: " + ioe, "Log Error", JOptionPane.ERROR_MESSAGE);
    }

    // force the initialization of IdGenerator on another thread so app can start now without an odd delay later
    new Thread() {
        public void run() {
            IdGenerator.generateId();
        }
    }.start();
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:71,代码来源:AppSetup.java

示例3: markOddRows

import javax.swing.UIManager; //导入方法依赖的package包/类
/**
 * Alternates the rows' color in the graphic table.
 */
private void markOddRows() {
	UIDefaults defaults = UIManager.getLookAndFeelDefaults();
	if (defaults.get("Table.alternateRowColor") == null) {
	    defaults.put("Table.alternateRowColor", new Color(ODD_ROW_R, ODD_ROW_G, ODD_ROW_B));
	}
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:10,代码来源:SelectedTableViewer.java

示例4: setDefaultColor

import javax.swing.UIManager; //导入方法依赖的package包/类
static void setDefaultColor() {

        Color      hsqlBlue  = new Color(102, 153, 204);
        Color      hsqlGreen = new Color(153, 204, 204);
        UIDefaults d         = UIManager.getLookAndFeelDefaults();

        d.put("MenuBar.background", SystemColor.control);
        d.put("Menu.background", SystemColor.control);
        d.put("Menu.selectionBackground", hsqlBlue);
        d.put("MenuItem.background", SystemColor.menu);
        d.put("MenuItem.selectionBackground", hsqlBlue);
        d.put("Separator.foreground", SystemColor.controlDkShadow);
        d.put("Button.background", SystemColor.control);
        d.put("CheckBox.background", SystemColor.control);
        d.put("Label.background", SystemColor.control);
        d.put("Label.foreground", Color.black);
        d.put("Panel.background", SystemColor.control);
        d.put("PasswordField.selectionBackground", hsqlGreen);
        d.put("PasswordField.background", SystemColor.white);
        d.put("TextArea.selectionBackground", hsqlGreen);
        d.put("TextField.background", SystemColor.white);
        d.put("TextField.selectionBackground", hsqlGreen);
        d.put("TextField.background", SystemColor.white);
        d.put("ScrollBar.background", SystemColor.controlHighlight);
        d.put("ScrollBar.foreground", SystemColor.control);
        d.put("ScrollBar.track", SystemColor.controlHighlight);
        d.put("ScrollBar.trackHighlight", SystemColor.controlDkShadow);
        d.put("ScrollBar.thumb", SystemColor.control);
        d.put("ScrollBar.thumbHighlight", SystemColor.controlHighlight);
        d.put("ScrollBar.thumbDarkShadow", SystemColor.controlDkShadow);
        d.put("ScrollBar.thumbLightShadow", SystemColor.controlShadow);
        d.put("ComboBox.background", SystemColor.control);
        d.put("ComboBox.selectionBackground", hsqlBlue);
        d.put("Table.background", SystemColor.white);
        d.put("Table.selectionBackground", hsqlBlue);
        d.put("TableHeader.background", SystemColor.control);

        // This doesn't seem to work.
        d.put("SplitPane.background", SystemColor.control);
        d.put("Tree.selectionBackground", hsqlBlue);
        d.put("List.selectionBackground", hsqlBlue);
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:43,代码来源:CommonSwing.java

示例5: tweakNimbusUI

import javax.swing.UIManager; //导入方法依赖的package包/类
private static void tweakNimbusUI() {
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    defaults.put("nimbusOrange", defaults.get("nimbusBase"));
    defaults.put("Table.gridColor", new Color(214, 217, 223));
    defaults.put("Table.disabled", false);
    defaults.put("Table.showGrid", true);
    defaults.put("Table.intercellSpacing", new Dimension(1, 1));
    defaults.put("CheckBoxMenuItem.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("RadioButtonMenuItem.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("MenuItem.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("Menu.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("Table.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("Label.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("TextField.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("TextArea.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("CheckBox.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("ComboBox.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("ToolTip.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("Button.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("TableHeader.font", new java.awt.Font("sansserif", 0, 11));
    defaults.put("FileChooser.font", new java.awt.Font("sansserif", 0, 11));
    /**
     * custom tab-area border painter
     */
    Painter tabborder = (Painter) (Graphics2D g, Object object, int width, int height) -> {
        //add code to customize
    };
    defaults.put("TabbedPane:TabbedPaneTabArea[Disabled].backgroundPainter", tabborder);
    defaults.put("TabbedPane:TabbedPaneTabArea[Enabled+MouseOver].backgroundPainter", tabborder);
    defaults.put("TabbedPane:TabbedPaneTabArea[Enabled+Pressed].backgroundPainter", tabborder);
    defaults.put("TabbedPane:TabbedPaneTabArea[Enabled].backgroundPainter", tabborder);
    PopupFactory.setSharedInstance(new PopupFactory() {
        @Override
        public Popup getPopup(Component owner, final Component contents, int x, int y) throws IllegalArgumentException {
            Popup popup = super.getPopup(owner, contents, x, y);
            SwingUtilities.invokeLater(() -> {
                contents.repaint();
            });
            return popup;
        }
    });
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:43,代码来源:Main.java


注:本文中的javax.swing.UIManager.getLookAndFeelDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。