List of usage examples for javax.swing.plaf FontUIResource getSize
public int getSize()
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
/** * @param args the command line arguments * @throws Exception/*from w ww . j av a2 s .c o m*/ */ public static void main(String args[]) throws Exception { QLog.initial(args, 3); Locale.setDefault(Locales.getInstance().getLangCurrent()); //? ? , ? final Thread tPager = new Thread(() -> { FAbout.loadVersionSt(); String result = ""; try { final URL url = new URL(PAGER_URL + "/qskyapi/getpagerdata?qsysver=" + FAbout.VERSION_); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Java bot"); conn.connect(); final int code = conn.getResponseCode(); if (code == 200) { try (BufferedReader in = new BufferedReader( new InputStreamReader(conn.getInputStream(), "utf8"))) { String inputLine; while ((inputLine = in.readLine()) != null) { result += inputLine; } } } conn.disconnect(); } catch (Exception e) { System.err.println("Pager not enabled. " + e); return; } final Gson gson = GsonPool.getInstance().borrowGson(); try { final Answer answer = gson.fromJson(result, Answer.class); forPager = answer; if (answer.getData().size() > 0) { forPager.start(); } } catch (Exception e) { System.err.println("Pager not enabled but working. " + e); } finally { GsonPool.getInstance().returnGson(gson); } }); tPager.setDaemon(true); tPager.start(); Uses.startSplash(); // plugins Uses.loadPlugins("./plugins/"); // ?. FLogin.logining(QUserList.getInstance(), null, true, 3, FLogin.LEVEL_ADMIN); Uses.showSplash(); java.awt.EventQueue.invokeLater(() -> { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager .getInstalledLookAndFeels()) { System.out.println(info.getName()); /*Metal Nimbus CDE/Motif Windows Windows Classic //GTK+*/ if ("Windows".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } if ("/".equals(File.separator)) { final FontUIResource f = new FontUIResource(new Font("Serif", Font.PLAIN, 10)); final Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); final Object value = UIManager.get(key); if (value instanceof FontUIResource) { final FontUIResource orig = (FontUIResource) value; final Font font1 = new Font(f.getFontName(), orig.getStyle(), f.getSize()); UIManager.put(key, new FontUIResource(font1)); } } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } try { form = new FAdmin(); if (forPager != null) { forPager.showData(false); } else { form.panelPager.setVisible(false); } form.setVisible(true); } catch (Exception ex) { QLog.l().logger().error(" ? ?? . ", ex); } finally { Uses.closeSplash(); } }); }
From source file:Main.java
public static void increaseDefaultFont(float multiplier) { for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value != null && value instanceof FontUIResource) { FontUIResource fontUIResource = (FontUIResource) value; UIManager.put(key, fontUIResource.deriveFont(fontUIResource.getSize() * multiplier)); }// w w w . j a v a2s .com } }
From source file:Main.java
/** * Sets the default UI font style.// w ww .j av a2 s . c o m * * @param fontStyle * The font style * @see Font See Font Javadoc for possible styles */ public static void setUIFontStyle(final int fontStyle) { for (Enumeration<?> en = UIManager.getDefaults().keys(); en.hasMoreElements();) { Object key = en.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { FontUIResource fontRes = (FontUIResource) value; UIManager.put(key, new ProxyLazyValue("javax.swing.plaf.FontUIResource", null, new Object[] { fontRes.getName(), fontStyle, fontRes.getSize() })); } } }
From source file:net.sf.jabref.JabRef.java
private void setLookAndFeel() { try {/* ww w . j ava 2 s. c o m*/ String lookFeel; String systemLnF = UIManager.getSystemLookAndFeelClassName(); if (Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL)) { // Use system Look & Feel by default lookFeel = systemLnF; } else { lookFeel = Globals.prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); } // At all cost, avoid ending up with the Metal look and feel: if ("javax.swing.plaf.metal.MetalLookAndFeel".equals(lookFeel)) { Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel(); Plastic3DLookAndFeel.setCurrentTheme(new SkyBluer()); com.jgoodies.looks.Options.setPopupDropShadowEnabled(true); UIManager.setLookAndFeel(lnf); } else { try { UIManager.setLookAndFeel(lookFeel); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { // specified look and feel does not exist on the classpath, so use system l&f UIManager.setLookAndFeel(systemLnF); // also set system l&f as default Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLnF); // notify the user JOptionPane.showMessageDialog(JabRef.jrf, Localization.lang( "Unable to find the requested Look & Feel and thus the default one is used."), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE); } } } catch (Exception e) { LOGGER.warn("Look and feel could not be set", e); } // In JabRef v2.8, we did it only on NON-Mac. Now, we try on all platforms boolean overrideDefaultFonts = Globals.prefs.getBoolean(JabRefPreferences.OVERRIDE_DEFAULT_FONTS); if (overrideDefaultFonts) { int fontSize = Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE); UIDefaults defaults = UIManager.getDefaults(); Enumeration<Object> keys = defaults.keys(); Double zoomLevel = null; for (Object key : Collections.list(keys)) { if ((key instanceof String) && ((String) key).endsWith(".font")) { FontUIResource font = (FontUIResource) UIManager.get(key); if (zoomLevel == null) { // zoomLevel not yet set, calculate it based on the first found font zoomLevel = (double) fontSize / (double) font.getSize(); } font = new FontUIResource(font.getName(), font.getStyle(), fontSize); defaults.put(key, font); } } if (zoomLevel != null) { GUIGlobals.zoomLevel = zoomLevel; } } }
From source file:edu.ku.brc.ui.UIRegistry.java
/** * Creates the initial font mapping from the base font size to the other sizes. * @param clazz the class of the component * @param baseFontArg the base font size */// www .ja v a 2 s. com protected static void adjustAllFonts(final Font oldBaseFont, final Font baseFontArg) { if (oldBaseFont != null && baseFontArg != null) { int fontSize = baseFontArg.getSize(); int oldFontSize = oldBaseFont.getSize(); String family = baseFontArg.getFamily(); UIDefaults uiDefaults = UIManager.getDefaults(); Enumeration<Object> e = uiDefaults.keys(); while (e.hasMoreElements()) { Object key = e.nextElement(); if (key.toString().endsWith(".font")) { FontUIResource fontUIRes = (FontUIResource) uiDefaults.get(key); if (fontSize != fontUIRes.getSize() || !family.equals(fontUIRes.getFamily())) { UIManager.put(key, new FontUIResource(new Font(family, fontUIRes.getStyle(), fontSize + (fontUIRes.getSize() - oldFontSize)))); } } } } }
From source file:shuffle.fwk.ShuffleController.java
/** * Creates a ShuffleController with the given configuration paths for the primary configuration * (which tells other managers where to get their configurations). If there are none passed, then * "config/main.txt" is assumed.// w ww. j a va2 s . co m * * @param configPaths * The paths as Strings */ public ShuffleController(String... configPaths) { if (configPaths.length > 0 && configPaths[0] != null) { factory = new ConfigFactory(configPaths[0]); } else { factory = new ConfigFactory(); } Integer menuFontOverride = getPreferencesManager().getIntegerValue(KEY_FONT_SIZE_SCALING); if (menuFontOverride != null && menuFontOverride != 100 && menuFontOverride >= 1 && menuFontOverride <= 10000) { float scale = menuFontOverride.floatValue() / 100.0f; try { // This is the cleanest and most bug-free way to do this hack. Set<Object> allKeys = new HashSet<Object>(); allKeys.add("JMenu.font"); // Yes we're not supposed to use this, but it is the only one that works with Nimbus LAF allKeys.addAll(UIManager.getLookAndFeelDefaults().keySet()); Object value = UIManager.get("defaultFont"); if (value != null && value instanceof FontUIResource) { FontUIResource fromFont = (javax.swing.plaf.FontUIResource) value; FontUIResource toFont = new FontUIResource(fromFont.deriveFont(fromFont.getSize() * scale)); // This one is necessary UIManager.getLookAndFeel().getDefaults().put("defaultFont", toFont); // And this one allows other LAF to be used in the future UIManager.getDefaults().put("defaultFont", toFont); } // Needed for Nimbus's JTable row height adjustment Object tableFontValue = UIManager.getLookAndFeel().getDefaults().get("Table.font"); Number bestRowHeight = null; if (tableFontValue != null && tableFontValue instanceof FontUIResource) { FontUIResource fromFont = (FontUIResource) tableFontValue; bestRowHeight = fromFont.getSize(); } Object rowHeightValue = UIManager.getLookAndFeel().getDefaults().get("Table.rowHeight"); if (rowHeightValue != null && rowHeightValue instanceof Number) { Number rowHeight = (Number) rowHeightValue; rowHeight = rowHeight.doubleValue() * scale; if (bestRowHeight == null || bestRowHeight.intValue() < rowHeight.intValue()) { bestRowHeight = rowHeight; } } if (bestRowHeight != null) { bestRowHeight = bestRowHeight.doubleValue() * (4.0 / 3.0); } if (bestRowHeight != null && bestRowHeight.intValue() > 0) { UIManager.getLookAndFeel().getDefaults().put("Table.rowHeight", bestRowHeight.intValue()); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOG.log(Level.SEVERE, "Cannot override menu font sizes!", e); } } try { setModel(new ShuffleModel(this)); setView(new ShuffleView(this)); getModel().checkLocaleConfig(); loadFrame(); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOG.log(Level.SEVERE, "Failure on start:", e); } }