Java Code Examples for javax.swing.UIManager#getFont()

The following examples show how to use javax.swing.UIManager#getFont() . 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: AboutPanel.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
    Graphics2D gc = GraphicsUtilities.prepare(g);
    super.paintComponent(gc);
    Images.ABOUT.paintIcon(this, gc, 0, 0);
    //noinspection IntegerDivisionInFloatingPointContext
    LinearGradientPaint gradient = new LinearGradientPaint(0, Images.ABOUT.getIconHeight() / 2, 0, Images.ABOUT.getIconHeight(), new float[]{0, 1}, new Color[]{new Color(0, 0, 0, 0), Color.black});
    gc.setPaint(gradient);
    gc.fillRect(0, 0, Images.ABOUT.getIconWidth(), Images.ABOUT.getIconHeight());
    RenderingHints saved = (RenderingHints) gc.getRenderingHints().clone();
    gc.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    gc.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    Font baseFont = UIManager.getFont("TextField.font");
    gc.setFont(baseFont.deriveFont(10.0f));
    gc.setColor(Color.WHITE);
    int right = getWidth() - HMARGIN;
    int y     = draw(gc, I18n.Text("GURPS is a trademark of Steve Jackson Games, used by permission. All rights reserved.\nThis product includes copyrighted material from the GURPS game, which is used by permission of Steve Jackson Games.\nThe iText Library is licensed under LGPL 2.1 by Bruno Lowagie and Paulo Soares.\nThe Trove Library is licensed under LGPL 2.1 by Eric D. Friedman and Rob Eden.\nThe PDFBox and FontBox libraries are licensed under the Apache License v2 by the Apache Software Foundation."), getHeight() - HMARGIN, right, true, true);
    int y2    = draw(gc, GCS.COPYRIGHT + "\nAll rights reserved", y, right, false, true);
    draw(gc, String.format(I18n.Text("%s %s\n%s Architecture\nJava %s"), System.getProperty("os.name"), System.getProperty("os.version"), System.getProperty("os.arch"), System.getProperty("java.version")), y, right, false, false);  //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    gc.setFont(baseFont.deriveFont(Font.BOLD, 12.0f));
    draw(gc, GCS.VERSION.isZero() ? I18n.Text("Development Version") : I18n.Text("Version ") + GCS.VERSION, y2, right, false, true);
    gc.setRenderingHints(saved);
}
 
Example 2
Source File: FontPreferences.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link FontPreferences}.
 *
 * @param owner The owning {@link PreferencesWindow}.
 */
public FontPreferences(PreferencesWindow owner) {
    super(I18n.Text("Fonts"), owner);
    FlexGrid grid = new FlexGrid();
    String[] keys = Fonts.getKeys();
    mFontPanels = new FontPanel[keys.length];
    int i = 0;
    for (String key : keys) {
        grid.add(new FlexComponent(createLabel(Fonts.getDescription(key), null), Alignment.RIGHT_BOTTOM, Alignment.CENTER), i, 0);
        mFontPanels[i] = new FontPanel(UIManager.getFont(key));
        mFontPanels[i].setActionCommand(key);
        mFontPanels[i].addActionListener(this);
        add(mFontPanels[i]);
        grid.add(mFontPanels[i], i, 1);
        i++;
    }
    grid.apply(this);
}
 
Example 3
Source File: NimbusStyle.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * Overridden to cause this style to populate itself with data from
 * UIDefaults, if necessary. If a value named "font" is not found in
 * UIDefaults, then the "defaultFont" font in UIDefaults will be returned
 * instead.
 */
@Override protected Font getFontForState(SynthContext ctx) {
    Font f = (Font)get(ctx, "font");
    if (f == null) f = UIManager.getFont("defaultFont");

    // Account for scale
    // The key "JComponent.sizeVariant" is used to match Apple's LAF
    String scaleKey = (String)ctx.getComponent().getClientProperty(
            "JComponent.sizeVariant");
    if (scaleKey != null){
        if (LARGE_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*LARGE_SCALE));
        } else if (SMALL_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*SMALL_SCALE));
        } else if (MINI_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*MINI_SCALE));
        }
    }
    return f;
}
 
Example 4
Source File: SeaGlassStyle.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the font for the specified state. This should NOT call any method
 * on the <code>JComponent</code>.
 *
 * <p>Overridden to cause this style to populate itself with data from
 * UIDefaults, if necessary. If a value named "font" is not found in
 * UIDefaults, then the "defaultFont" font in UIDefaults will be returned
 * instead.</p>
 *
 * @param  ctx context SynthContext identifying requester
 *
 * @return Font to render with
 */
@Override
protected Font getFontForState(SynthContext ctx) {
    Font f = (Font) get(ctx, "font");

    if (f == null)
        f = UIManager.getFont("defaultFont");

    // Account for scale
    // The key "JComponent.sizeVariant" is used to match Apple's LAF
    String scaleKey = SeaGlassStyle.getSizeVariant(ctx.getComponent());
    if (scaleKey != null) {
        if (LARGE_KEY.equals(scaleKey)) {
            f = f.deriveFont(Math.round(f.getSize2D() * LARGE_SCALE));
        } else if (SMALL_KEY.equals(scaleKey)) {
            f = f.deriveFont(Math.round(f.getSize2D() * SMALL_SCALE));
        } else if (MINI_KEY.equals(scaleKey)) {
            f = f.deriveFont(Math.round(f.getSize2D() * MINI_SCALE));
        }
    }

    return f;

}
 
Example 5
Source File: JCheckBoxTree.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public CheckBoxNodeRenderer() {
    Font fontValue;
    fontValue = UIManager.getFont("Tree.font");
    if (fontValue != null) {
        leafRenderer.setFont(fontValue);
    }
    Boolean booleanValue = (Boolean) UIManager
            .get("Tree.drawsFocusBorderAroundIcon");
    leafRenderer.setFocusPainted((booleanValue != null)
            && (booleanValue.booleanValue()));
    
    selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor");
    selectionForeground = UIManager.getColor("Tree.selectionForeground");
    selectionBackground = UIManager.getColor("Tree.selectionBackground");
    textForeground = UIManager.getColor("Tree.textForeground");
    textBackground = UIManager.getColor("Tree.textBackground");
}
 
Example 6
Source File: NimbusStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * Overridden to cause this style to populate itself with data from
 * UIDefaults, if necessary. If a value named "font" is not found in
 * UIDefaults, then the "defaultFont" font in UIDefaults will be returned
 * instead.
 */
@Override protected Font getFontForState(SynthContext ctx) {
    Font f = (Font)get(ctx, "font");
    if (f == null) f = UIManager.getFont("defaultFont");

    // Account for scale
    // The key "JComponent.sizeVariant" is used to match Apple's LAF
    String scaleKey = (String)ctx.getComponent().getClientProperty(
            "JComponent.sizeVariant");
    if (scaleKey != null){
        if (LARGE_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*LARGE_SCALE));
        } else if (SMALL_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*SMALL_SCALE));
        } else if (MINI_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*MINI_SCALE));
        }
    }
    return f;
}
 
Example 7
Source File: NimbusStyle.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * Overridden to cause this style to populate itself with data from
 * UIDefaults, if necessary. If a value named "font" is not found in
 * UIDefaults, then the "defaultFont" font in UIDefaults will be returned
 * instead.
 */
@Override protected Font getFontForState(SynthContext ctx) {
    Font f = (Font)get(ctx, "font");
    if (f == null) f = UIManager.getFont("defaultFont");

    // Account for scale
    // The key "JComponent.sizeVariant" is used to match Apple's LAF
    String scaleKey = (String)ctx.getComponent().getClientProperty(
            "JComponent.sizeVariant");
    if (scaleKey != null){
        if (LARGE_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*LARGE_SCALE));
        } else if (SMALL_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*SMALL_SCALE));
        } else if (MINI_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*MINI_SCALE));
        }
    }
    return f;
}
 
Example 8
Source File: FlatViewTabDisplayerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected Font getTxtFont() {
    if (font == null) {
        font = UIManager.getFont("ViewTab.font"); // NOI18N
        if (font == null) {
            font = UIManager.getFont("Label.font"); // NOI18N
        }
    }
    return font;
}
 
Example 9
Source File: MovWriterDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
protected void paintComponent(Graphics g) {
	float time = animationController.getTime();
	int frame = (int) (time * ((Number) fpsSpinner.getValue())
			.intValue());
	p.paintFrame(g.create(), getWidth(), getHeight(), frame);

	g.setColor(Color.black);
	Font f = UIManager.getFont("Label.font");
	g.setFont(f);
	g.drawString("f = " + frame, 3, (int) (f.getSize2D() + 4));
	g.drawString("t = " + time, 3, (int) (2 * f.getSize2D() + 8));
}
 
Example 10
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static int getDefaultFontSize() {
    Integer customFontSize = (Integer)UIManager.get("customFontSize"); // NOI18N
    if (customFontSize != null) {
        return customFontSize.intValue();
    } else {
        Font systemDefaultFont = UIManager.getFont("TextField.font"); // NOI18N
        return (systemDefaultFont != null)
            ? systemDefaultFont.getSize()
            : 11;
    }
}
 
Example 11
Source File: TabPanelPopulation.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		JPanel titlePane = new JPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		JLabel heading = new JLabel(Msg.getString("TabPanelPopulation.title"), JLabel.CENTER); //$NON-NLS-1$
		heading.setFont(new Font("Serif", Font.BOLD, 16));
		//heading.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(heading);

		// Prepare count spring layout panel.
		WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);
		
		// Create population indoor label
		WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelPopulation.indoor"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationIndoorHeader);
		
		populationIndoorCache = settlement.getIndoorPeopleCount();
		populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT);
		countPanel.add(populationIndoorLabel);
		
		// Create population capacity label
		WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelPopulation.capacity"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationCapacityHeader);
		
		populationCapacityCache = settlement.getPopulationCapacity();
		populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT);
		countPanel.add(populationCapacityLabel);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(countPanel, 2, 2, // rows, cols
				25, 10, // initX, initY
				10, 10); // xPad, yPad
		
        UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray);
        Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelPopulation.title") + " ");
//      title.setTitleJustification(TitledBorder.RIGHT);
        Font titleFont = UIManager.getFont("TitledBorder.font");
        title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD));
        
		// Create spring layout population display panel
		JPanel populationDisplayPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		populationDisplayPanel.setBorder(title);
		topContentPanel.add(populationDisplayPanel);

		// Create scroll panel for population list.
		populationScrollPanel = new JScrollPane();
		populationScrollPanel.setPreferredSize(new Dimension(200, 250));
		populationDisplayPanel.add(populationScrollPanel);

		// Create population list model
		populationListModel = new PopulationListModel(settlement);

		// Create population list
		populationList = new JList<Person>(populationListModel);
		populationList.addMouseListener(this);
		populationScrollPanel.setViewportView(populationList);

		// Create population monitor button
		JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelPopulation.tooltip.monitor")); //$NON-NLS-1$
		populationDisplayPanel.add(monitorButton);

	}
 
Example 12
Source File: HeapView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the look and feel for this component.
 */
@Override
public void updateUI() {
    Font f = UIManager.getFont("Label.font");
    setFont(f);
}
 
Example 13
Source File: GraphicsTestCase.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Determine if the graphics environment is 24 bit and has standard fonts,
 * so pixel position and color tests will not erroneously fail.  This method is
 * thread safe.
 */
public static boolean canSafelyRunPixelTests() {
    if (graphicsTestsSafe != null) {
        return graphicsTestsSafe.booleanValue();
    }
    
    try {
        boolean result = false;
        if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadless()) {
            System.err.println("Cannot run test in a headless environment");
            graphicsTestsSafe = Boolean.FALSE;
            return false;
        }
        
        DisplayMode dm =
                GraphicsEnvironment.getLocalGraphicsEnvironment().
                getDefaultScreenDevice().getDisplayMode();
        
        int i = dm.getBitDepth();
        if (i == dm.BIT_DEPTH_MULTI || i >= 16) {
            result = true;
            
            Font f = UIManager.getFont("controlFont");
            if (f == null) {
                f = new JTable().getFont();
            }
            Graphics g = GraphicsEnvironment.getLocalGraphicsEnvironment().
                    getDefaultScreenDevice().getDefaultConfiguration().
                    createCompatibleImage(10,10).getGraphics();
            
            FontMetrics fm = g.getFontMetrics(f);
            if (fm.getHeight() != 16) {
                System.err.println("Cannot run this test - default font size is not " + 16 + " pixels in height - could lead to false fails");
                System.err.println("Basic font size is " + fm.getHeight());
                //Some environments, such as Mandrake linux or Windows with
                //large fonts will supply fonts bigger than the error icon,
                //causing the pixel tests to fail due to icon positioning
                //differences
                result = false;
            }
        }
        if (result) {
            result = tryPrototypePixelTest();
        }
        return result;
    } catch (Exception e) {
        graphicsTestsSafe = Boolean.FALSE;
        e.printStackTrace();
        return false;
    }
}
 
Example 14
Source File: ListTextCell.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public Font getFont(Row row, Column column) {
    return UIManager.getFont(Fonts.KEY_FIELD_PRIMARY);
}
 
Example 15
Source File: MarginViewportUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void installUI(JComponent c) {
    super.installUI(c);

    //Fetch the "no properties" string - it's not going to change
    //for the life of the session
    //        noPropsString = NbBundle.getMessage(MarginViewportUI.class,
    //            "CTL_NoProperties"); //NOI18N
    //Set an appropriate font and color.  Only really relevant on OS-X to
    //keep the font consistent with other NB fonts
    Color fg = UIManager.getColor("controlShadow"); //NOI18N

    if (fg == null) {
        fg = Color.LIGHT_GRAY;
    }

    c.setForeground(fg);

    Color bg = UIManager.getColor("Tree.background"); //NOI18N

    if (bg == null) {
        bg = Color.WHITE;
    }

    c.setBackground(bg);

    Font f = UIManager.getFont("Tree.font"); //NOI18N

    if (f == null) {
        f = UIManager.getFont("controlFont"); //NOI18N
    }

    if (f != null) {
        c.setFont(f);
    }

    c.addContainerListener(this);

    Component[] kids = c.getComponents();

    for (int i = 0; i < kids.length; i++) {
        //Should almost always be empty anyway, if not only one component,
        //but for completeness...
        kids[i].addComponentListener(this);
    }
}
 
Example 16
Source File: Main.java    From swingsane with Apache License 2.0 4 votes vote down vote up
/**
 * Fixes a variety of ugly default GUI settings for Swing on Linux.
 */
private static void initLinuxLAF() {
  try {
    System.setProperty("awt.useSystemAAFontSettings", "on");
    Font oldLabelFont = UIManager.getFont("Label.font");
    UIManager.put("Label.font", oldLabelFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldButtonFont = UIManager.getFont("Button.font");
    UIManager.put("Button.font", oldButtonFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldCheckBoxFont = UIManager.getFont("CheckBox.font");
    UIManager.put("CheckBox.font", oldCheckBoxFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldRadioButtonFont = UIManager.getFont("RadioButton.font");
    UIManager.put("RadioButton.font", oldRadioButtonFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldComboBoxFont = UIManager.getFont("ComboBox.font");
    UIManager.put("ComboBox.font", oldComboBoxFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldColorChooserFont = UIManager.getFont("ColorChooser.font");
    UIManager.put("ColorChooser.font", oldColorChooserFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldListFont = UIManager.getFont("List.font");
    UIManager.put("List.font", oldListFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldOptionPaneFont = UIManager.getFont("OptionPane.font");
    UIManager.put("OptionPane.font", oldOptionPaneFont.deriveFont(Font.PLAIN, 12.0f));
    UIManager.put("OptionPane.messageFont", oldOptionPaneFont.deriveFont(Font.PLAIN, 12.0f));
    UIManager.put("OptionPane.buttonFont", oldButtonFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldPanelFont = UIManager.getFont("Panel.font");
    UIManager.put("Panel.font", oldPanelFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldProgressBarFont = UIManager.getFont("ProgressBar.font");
    UIManager.put("ProgressBar.font", oldProgressBarFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldScrollPaneFont = UIManager.getFont("ScrollPane.font");
    UIManager.put("ScrollPane.font", oldScrollPaneFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldViewportFont = UIManager.getFont("Viewport.font");
    UIManager.put("Viewport.font", oldViewportFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTextPaneFont = UIManager.getFont("TextPane.font");
    UIManager.put("TextPane.font", oldTextPaneFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldEditorPaneFont = UIManager.getFont("EditorPane.font");
    UIManager.put("EditorPane.font", oldEditorPaneFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldToolTipFont = UIManager.getFont("ToolTip.font");
    UIManager.put("ToolTip.font", oldToolTipFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTreeFont = UIManager.getFont("Tree.font");
    UIManager.put("Tree.font", oldTreeFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldToggleButtonFont = UIManager.getFont("ToggleButton.font");
    UIManager.put("ToggleButton.font", oldToggleButtonFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTabbedPaneFont = UIManager.getFont("TabbedPane.font");
    UIManager.put("TabbedPane.font", oldTabbedPaneFont.deriveFont(Font.PLAIN, 13.0f));
    Font oldTableFont = UIManager.getFont("Table.font");
    UIManager.put("Table.font", oldTableFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTextFieldFont = UIManager.getFont("TextField.font");
    UIManager.put("TextField.font", oldTextFieldFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldPasswordFieldFont = UIManager.getFont("PasswordField.font");
    UIManager.put("PasswordField.font", oldPasswordFieldFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTextAreaFont = UIManager.getFont("TextArea.font");
    UIManager.put("TextArea.font", oldTextAreaFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldToolBarFont = UIManager.getFont("ToolBar.font");
    UIManager.put("ToolBar.font", oldToolBarFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTableHeaderFont = UIManager.getFont("TableHeader.font");
    UIManager.put("TableHeader.font", oldTableHeaderFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldSpinnerFont = UIManager.getFont("Spinner.font");
    UIManager.put("Spinner.font", oldSpinnerFont.deriveFont(Font.PLAIN, 11.0f));
    Font oldTitledBorderFont = UIManager.getFont("TitledBorder.font");
    UIManager.put("TitledBorder.font", oldTitledBorderFont.deriveFont(Font.BOLD, 11.0f));
    Font oldMenuItemFont = UIManager.getFont("MenuItem.font");
    UIManager.put("MenuItem.font", oldMenuItemFont.deriveFont(Font.PLAIN, 12.0f));
    Font oldMenuFont = UIManager.getFont("Menu.font");
    UIManager.put("Menu.font", oldMenuFont.deriveFont(Font.PLAIN, 12.0f));
    Font oldPopupMenuFont = UIManager.getFont("PopupMenu.font");
    UIManager.put("PopupMenu.font", oldPopupMenuFont.deriveFont(Font.PLAIN, 12.0f));
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  } catch (Exception ex) {
    LOG.warn(ex, ex);
  }
}
 
Example 17
Source File: Main.java    From gate-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Reads the user config data and applies the required settings.
 * This must be called <b>after</b> {@link Gate#init()} but <b>before</b>
 * any GUI components are created.
 */
public static void applyUserPreferences(){
  //look and feel
  String lnfClassName;
  if(System.getProperty("swing.defaultlaf") != null) {
    lnfClassName = System.getProperty("swing.defaultlaf");
  } else {
    lnfClassName = Gate.getUserConfig().
                          getString(GateConstants.LOOK_AND_FEEL);
  }
  if(lnfClassName == null){
    //if running on Linux, default to Metal rather than GTK because GTK LnF
    //doesn't play nicely with most Gnome themes
    if(System.getProperty("os.name").toLowerCase().indexOf("linux") != -1){
      //running on Linux
      lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName();
    }else{
      lnfClassName = UIManager.getSystemLookAndFeelClassName();
    }      
  }
  try {
    UIManager.setLookAndFeel(lnfClassName);
  } catch(Exception e) {
    System.err.print("Could not set your preferred Look and Feel. The error was:\n" +
            e.toString() + "\nReverting to using Java Look and Feel");
    try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    }catch(Exception e1) {
      //we just can't catch a break here. Let's forget about look and feel.
      System.err.print(
              "Could not set the cross-platform Look and Feel either. The error was:\n" +
              e1.toString() + "\nGiving up on Look and Feel.");
    }
  }
  Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName);
  
  //read the user config data
  OptionsMap userConfig = Gate.getUserConfig();

  //text font
  Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT);
  if(font == null){
    font = UIManager.getFont("TextPane.font");
  }

  if(font != null){
    OptionsDialog.setTextComponentsFont(font);
  }

  //menus font
  font = userConfig.getFont(GateConstants.MENUS_FONT);
  if(font == null){
    font = UIManager.getFont("Menu.font");
  }

  if(font != null){
    OptionsDialog.setMenuComponentsFont(font);
  }

  //other gui font
  font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT);
  if(font == null){
    font = UIManager.getFont("Button.font");
  }

  if(font != null){
    OptionsDialog.setComponentsFont(font);
  }

}
 
Example 18
Source File: TitledBorder.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the title-font of the titled border.
 *
 * @return the title-font of the titled border
 */
public Font getTitleFont() {
    return titleFont == null ? UIManager.getFont("TitledBorder.font") : titleFont;
}
 
Example 19
Source File: TitledBorder.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the title-font of the titled border.
 *
 * @return the title-font of the titled border
 */
public Font getTitleFont() {
    return titleFont == null ? UIManager.getFont("TitledBorder.font") : titleFont;
}
 
Example 20
Source File: TitledBorder.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the title-font of the titled border.
 *
 * @return the title-font of the titled border
 */
public Font getTitleFont() {
    return titleFont == null ? UIManager.getFont("TitledBorder.font") : titleFont;
}