Java Code Examples for javax.swing.UIManager#getLookAndFeelDefaults()
The following examples show how to use
javax.swing.UIManager#getLookAndFeelDefaults() .
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 File: LittleLuckLookAndFeel.java From littleluck with Apache License 2.0 | 6 votes |
/** * setting global font. * * @param f Font object */ public void setApplicationFont(Font f) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); synchronized (defaults) { for (Object ui_property : defaults.keySet()) { if (ui_property.toString().endsWith(".font")) { UIManager.put(ui_property, f); } } } }
Example 2
Source File: RapidLookAndFeel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@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<Object, Object> copy = new Hashtable<>(lookAndFeelDefaults != null ? lookAndFeelDefaults : Collections.emptyMap()); 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; }
Example 3
Source File: ThemeChanges.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
public static void setDefaults() { try { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); defaults.put("nimbusOrange", new Color(0xFF01D328)); Object o = UIManager.get("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.iconifyButton\"[Enabled].backgroundPainter"); Class<?> c = o.getClass(); Field f = c.getDeclaredField("color3"); f.setAccessible(true); f.set(o, new Color(0xFF01D328)); } catch (Exception e) { JByteMod.LOGGER.err("Failed to apply nimbus theme changes"); } }
Example 4
Source File: LookAndFeelAddons.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
/** * With applets, if you reload the current applet, the UIManager will be * reinitialized (entries previously added by LookAndFeelAddons will be * removed) but the addon will not reinitialize because addon initialize * itself through the static block in components and the classes do not get * reloaded. This means component.updateUI will fail because it will not find * its UI. * * This method ensures LookAndFeelAddons get re-initialized if needed. It must * be called in every component updateUI methods. */ private static synchronized void maybeInitialize() { if (currentAddon != null) { // this is to ensure "UIManager#maybeInitialize" gets called and the // LAFState initialized UIManager.getLookAndFeelDefaults(); if (!UIManager.getBoolean(APPCONTEXT_INITIALIZED)) { setAddon(currentAddon); } } }
Example 5
Source File: LookAndFeelAddons.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * With applets, if you reload the current applet, the UIManager will be * reinitialized (entries previously added by LookAndFeelAddons will be * removed) but the addon will not reinitialize because addon initialize * itself through the static block in components and the classes do not get * reloaded. This means component.updateUI will fail because it will not find * its UI. * * This method ensures LookAndFeelAddons get re-initialized if needed. It must * be called in every component updateUI methods. */ private static synchronized void maybeInitialize() { if (currentAddon != null) { // this is to ensure "UIManager#maybeInitialize" gets called and the // LAFState initialized UIManager.getLookAndFeelDefaults(); if (!UIManager.getBoolean(APPCONTEXT_INITIALIZED)) { setAddon(currentAddon); } } }
Example 6
Source File: Main.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 4 votes |
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; } }); }
Example 7
Source File: BEToolBarSeparatorUI.java From beautyeye with Apache License 2.0 | 4 votes |
public void paint( Graphics g, JComponent c ) { boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL; Dimension size = c.getSize(); //虚线样式 Stroke oldStroke = ((Graphics2D)g).getStroke(); Stroke sroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{2, 2}, 0);//实线,空白 ((Graphics2D)g).setStroke(sroke);// Color temp = g.getColor(); UIDefaults table = UIManager.getLookAndFeelDefaults(); Color shadow = table.getColor("ToolBar.shadow"); Color highlight = table.getColor("ToolBar.highlight"); // TODO BUG_001:不知何故,垂直分隔条并不能像水平分隔条一样,拥有默认设置的new Dimension(6, 6) // 而只有new Dimension(1, ...),而当它floating时却能正常表现(只能绘出hilight而不能绘出shadow) //,有待深入研究,垂直的分隔条则不会有此种情况 if (vertical) { int x = (size.width / 2) - 1; //* 当BUG_001存在时,暂时使用以下代码解决:把本该显示hilight的 //* 线条用shadow颜色绘制,最大可能保证ui的正常展现 // g.setColor(shadow); // g.drawLine(x, 2, x, size.height - 2); g.setColor(shadow);//highlight); g.drawLine(x + 1, 2, x + 1, size.height - 2); //* 当BUG_001不存在时,应该使用以下代码 // g.setColor(shadow); // g.drawLine(x, 2, x, size.height - 2); // g.setColor(highlight); // g.drawLine(x + 1, 2, x + 1, size.height - 2); } else { int y = (size.height / 2) - 1; g.setColor(shadow); g.drawLine(2, y, size.width - 2, y); g.setColor(highlight); g.drawLine(2, y + 1, size.width - 2, y + 1); } g.setColor(temp); // ((Graphics2D)g).setStroke(oldStroke); }
Example 8
Source File: LaFHelper.java From magarena with GNU General Public License v3.0 | 4 votes |
public static void setDefaultLookAndFeel() { if (trySetNimbusLookAndFeel()) { final UIDefaults defaults = UIManager.getLookAndFeelDefaults(); // // ** JTable // defaults.put("Table.showGrid", true); // theme-based selection background color. final Color oldColor = MagicStyle.getTheme().getColor(Theme.COLOR_TITLE_BACKGROUND); final Color newColor = ColorHelper.bleach1(oldColor, 0.2f); defaults.put("Table[Enabled+Selected].textBackground", newColor); // // ** JList // // set JList selection colors the same as JTable. defaults.put("List[Selected].textBackground", defaults.getColor("Table[Enabled+Selected].textBackground")); defaults.put("List[Selected].textForeground", defaults.getColor("Table[Enabled+Selected].textForeground")); // // ** JScrollPane // // removes hardcoded border defaults.put("ScrollPane[Enabled].borderPainter", null); // // ** JScrollBar // // custom scrollbar if (GeneralConfig.get(BooleanSetting.CUSTOM_SCROLLBAR)) { defaults.put("ScrollBarUI", "magic.ui.widget.scrollbar.MScrollBarUI"); final Dimension d = (Dimension) UIManager.get("ScrollBar.minimumThumbSize"); defaults.put("ScrollBar.minimumThumbSize", new Dimension( d.width < 50 ? 50 : d.width, d.height < 50 ? 50 : d.height) ); } } }
Example 9
Source File: IOSImageUtil.java From ios-image-util with MIT License | 4 votes |
public static void main(String[] args) { try { /* Mac OS X El Capitan has a little problem with mac look and feel. Ignore it. for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getClassName().equals("com.apple.laf.AquaLookAndFeel")) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "ios-image-util"); UIManager.setLookAndFeel(info.getClassName()); break; } } */ // Use anti-aliasing font on Windows platform in Japanese by default. System.setProperty("awt.useSystemAAFontSettings", "lcd"); // Maybe not effective. Don't care. ResourceBundle resource = ResourceBundle.getBundle("application"); if (resource.containsKey("font.default.name") && System.getProperty("file.separator").equals("\\")) { // Windows only UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults(); for (Enumeration<Object> enu = uiDefaults.keys(); enu.hasMoreElements();) { String key = enu.nextElement().toString(); Font font; if (key.toLowerCase().endsWith("font") && (font = uiDefaults.getFont(key)) != null) { uiDefaults.put(key, new Font(resource.getString("font.default.name"), font.getStyle(), font.getSize())); } } } long l1 = System.currentTimeMillis(); MainFrame mainFrame = new MainFrame(); mainFrame.setLocationByPlatform(true); File defaultProperties = new File(getDefaultDirectory(mainFrame), DEFAULT_PROPERTIES_FILENAME); if (defaultProperties.exists()) { boolean loadSystemProperties = true; boolean forceNew = false; for (int i = 0; i < args.length; i++) { String arg = args[i].toLowerCase(); if (arg.startsWith("/")) arg = "-".concat(arg.substring(1)); if (arg.equals("-r") || arg.equals("-reset")) { loadSystemProperties = false; break; } if (arg.equals("-b") || arg.equals("-batch")) { loadSystemProperties = false; break; } if (arg.equals("-h") || arg.equals("-help")) { loadSystemProperties = false; break; } if (arg.equals("-n") || arg.equals("-new")) { forceNew = true; } } if (loadSystemProperties) { mainFrame.loadProperties(defaultProperties, true, forceNew); } } if (args.length > 0) { if (!initialize(mainFrame, args)) { if (mainFrame.isBatchMode()) { System.exit(1); } } } if (mainFrame.isBatchMode()) { int exitCode = 0; if (!mainFrame.isSilentMode()) { System.out.println(String.format("START: %s", (new java.util.Date(l1)).toString())); System.out.println(String.format(" Initializing takes %.2f secs.", ((double)(System.currentTimeMillis() - l1) / 1000d))); System.out.println(); } if (mainFrame.isGenerateImagesReqested() && !mainFrame.generate()) { exitCode = 1; usage(mainFrame); } if (mainFrame.isSplitImageRequested() && !mainFrame.batchSplit()) { exitCode = 1; usage(mainFrame); } long l2 = System.currentTimeMillis(); if (!mainFrame.isSilentMode()) { System.out.println(String.format("FINISH: %s", (new java.util.Date(l2)).toString())); System.out.println(String.format(" Generate images takes %.2f secs.", ((double)(l2 - l1) / 1000d))); System.out.println(); } System.exit(exitCode); } else { if (mainFrame.isCheckForUpdatesOnStartUp()) { mainFrame.checkForUpdatesInBackground(); } mainFrame.initializeGUI(); mainFrame.setVisible(true); } } catch (Throwable t) { t.printStackTrace(System.err); System.exit(1); } }