List of usage examples for javax.swing.plaf FontUIResource getSize2D
public float getSize2D()
From source file:jshm.gui.GuiUtil.java
/** * This sets the default L&F as well as sets some icons *///from w ww.j a v a 2 s. c o m public static void init() { try { // Set the Look & Feel to match the current system UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } // http://www.java2s.com/Tutorial/Java/0240__Swing/CustomizingaJOptionPaneLookandFeel.htm UIManager.put("OptionPane.errorIcon", new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/delete.png"))); UIManager.put("OptionPane.informationIcon", new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/infoabout.png"))); UIManager.put("OptionPane.questionIcon", new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/help.png"))); UIManager.put("OptionPane.warningIcon", new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/pause.png"))); UIManager.put("OptionPane.yesIcon", new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/accept32.png"))); UIManager.put("OptionPane.noIcon", new ImageIcon(GuiUtil.class.getResource("/jshm/resources/images/toolbar/delete32.png"))); float scale = Config.getFloat("font.scale"); if (1f != scale) { LOG.finest("setting ui font scale to + " + scale); Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { FontUIResource f = (FontUIResource) value; f = new FontUIResource(f.deriveFont(scale * f.getSize2D())); UIManager.put(key, f); } } } // hook into the wizard displayer System.setProperty("WizardDisplayer.default", "jshm.gui.wizards.displayer.WizardDisplayerImpl"); }
From source file:org.yccheok.jstock.gui.JStock.java
/** * @param args the command line arguments */// w w w. j a va 2s .c o m public static void main(String args[]) { /*********************************************************************** * UI Manager initialization via JStockOptions. **********************************************************************/ final JStockOptions jStockOptions = getJStockOptionsViaXML(); // OSX menu bar at top. if (Utils.isMacOSX()) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("apple.awt.brushMetalLook", "true"); } boolean uiManagerLookAndFeelSuccess = false; try { String lookNFeel = jStockOptions.getLooknFeel(); if (null != lookNFeel) { UIManager.setLookAndFeel(lookNFeel); uiManagerLookAndFeelSuccess = true; } } catch (java.lang.ClassNotFoundException | java.lang.InstantiationException | java.lang.IllegalAccessException | javax.swing.UnsupportedLookAndFeelException exp) { log.error(null, exp); } if (!uiManagerLookAndFeelSuccess) { String className = Utils.setDefaultLookAndFeel(); if (null != className) { final String lookNFeel = jStockOptions.getLooknFeel(); // When jStockOptions.getLookNFeel returns null, it means we wish // to use system default value. Hence, don't overwrite the null value, // so that we can use the same jStockOptions, across different // platforms. if (lookNFeel != null) { jStockOptions.setLooknFeel(className); } } } /*********************************************************************** * Ensure correct localization. **********************************************************************/ // This global effect, should just come before anything else, // after we get an instance of JStockOptions. Locale.setDefault(jStockOptions.getLocale()); /*********************************************************************** * Single application instance enforcement. **********************************************************************/ if (false == AppLock.lock()) { final int choice = JOptionPane.showOptionDialog(null, MessagesBundle.getString("warning_message_running_2_jstock"), MessagesBundle.getString("warning_title_running_2_jstock"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { MessagesBundle.getString("yes_button_running_2_jstock"), MessagesBundle.getString("no_button_running_2_jstock") }, MessagesBundle.getString("no_button_running_2_jstock")); if (choice != JOptionPane.YES_OPTION) { System.exit(0); return; } } // Avoid "JavaFX IllegalStateException when disposing JFXPanel in Swing" // http://stackoverflow.com/questions/16867120/javafx-illegalstateexception-when-disposing-jfxpanel-in-swing Platform.setImplicitExit(false); // As ProxyDetector is affected by system properties // http.proxyHost, we are forced to initialized ProxyDetector right here, // before we manually change the system properties according to // JStockOptions. ProxyDetector.getInstance(); /*********************************************************************** * Apply large font if possible. **********************************************************************/ if (jStockOptions.useLargeFont()) { java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value != null && value instanceof javax.swing.plaf.FontUIResource) { javax.swing.plaf.FontUIResource fr = (javax.swing.plaf.FontUIResource) value; UIManager.put(key, new javax.swing.plaf.FontUIResource( fr.deriveFont((float) fr.getSize2D() * (float) Constants.FONT_ENLARGE_FACTOR))); } } } /*********************************************************************** * GA tracking. **********************************************************************/ GA.trackAsynchronously("main"); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { final JStock mainFrame = JStock.instance(); // We need to first assign jStockOptions to mainFrame, as during // Utils.migrateXMLToCSVPortfolios, we will be accessing mainFrame's // jStockOptions. mainFrame.initJStockOptions(jStockOptions); mainFrame.init(); mainFrame.setVisible(true); mainFrame.updateDividerLocation(); mainFrame.requestFocusOnJComboBox(); } }); }