當前位置: 首頁>>代碼示例>>Java>>正文


Java FontUIResource類代碼示例

本文整理匯總了Java中javax.swing.plaf.FontUIResource的典型用法代碼示例。如果您正苦於以下問題:Java FontUIResource類的具體用法?Java FontUIResource怎麽用?Java FontUIResource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FontUIResource類屬於javax.swing.plaf包,在下文中一共展示了FontUIResource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFontConfigFUIR

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
@Override
protected FontUIResource getFontConfigFUIR(String family, int style, int size) {

    CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style);

    if (font2D == null) { // Not expected, just a precaution.
       return new FontUIResource(family, style, size);
    }

    /* The name of the font will be that of the physical font in slot,
     * but by setting the handle to that of the CompositeFont it
     * renders as that CompositeFont.
     * It also needs to be marked as a created font which is the
     * current mechanism to signal that deriveFont etc must copy
     * the handle from the original font.
     */
    FontUIResource fuir =
        new FontUIResource(font2D.getFamilyName(null), style, size);
    FontAccess.getFontAccess().setFont2D(fuir, font2D.handle);
    FontAccess.getFontAccess().setCreatedFont(fuir);
    return fuir;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:X11FontManager.java

示例2: setupKeyColumnWidth

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
private void setupKeyColumnWidth() {
    FontUIResource font = (FontUIResource) UIManager.get("Table.font");
    for (int j = 0; j < getColumnModel().getColumnCount(); j++) {
        TableColumn column = getColumnModel().getColumn(j);
        Integer columnWidth = columnWidthMap.get(j);
        if (columnWidth != null) {
            int fixedSize = columnWidth;
            if (fixedSize == -1) {
                double max = 0;
                int rowCount = getModel().getRowCount();
                for (int i = 0; i < rowCount; i++) {
                    String text = getValueAt(i, 0).toString();
                    int width = SwingUtils.getWidth(font, text);
                    max = Math.max(max, width);
                }
                fixedSize = (int) (max + 16 * 2);
            }
            column.setMinWidth(fixedSize);
            column.setMaxWidth(fixedSize);
        }
    }
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:23,代碼來源:FSTable.java

示例3: initGlobalFont

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 * 設置全局字體
 */
public static void initGlobalFont() {

    String lowDpiKey = "lowDpiInit";
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //得到屏幕的尺寸
    if (screenSize.width <= 1366 && StringUtils.isEmpty(configer.getProps(lowDpiKey))) {
        configer.setFontSize(15);
        configer.setProps(lowDpiKey, "true");
        configer.save();
    }

    Font fnt = new Font(configer.getFont(), Font.PLAIN, configer.getFontSize());
    FontUIResource fontRes = new FontUIResource(fnt);
    for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements(); ) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource)
            UIManager.put(key, fontRes);
    }
}
 
開發者ID:rememberber,項目名稱:WePush,代碼行數:23,代碼來源:Init.java

示例4: initFontDefaults

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
@SuppressWarnings({"HardCodedStringLiteral"})
static void initFontDefaults(UIDefaults defaults, String fontFace, int fontSize) {
  defaults.put("Tree.ancestorInputMap", null);
  FontUIResource uiFont = new FontUIResource(fontFace, Font.PLAIN, fontSize);
  FontUIResource textFont = new FontUIResource("Serif", Font.PLAIN, fontSize);
  FontUIResource monoFont = new FontUIResource("Monospaced", Font.PLAIN, fontSize);

  for (String fontResource : ourPatchableFontResources) {
    defaults.put(fontResource, uiFont);
  }

  defaults.put("PasswordField.font", monoFont);
  defaults.put("TextArea.font", monoFont);
  defaults.put("TextPane.font", textFont);
  defaults.put("EditorPane.font", textFont);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:LafManagerImpl.java

示例5: register

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
public void register(ConverterRegistry registry) {
  registry.addConverter(Dimension.class, String.class, this);
  registry.addConverter(String.class, Dimension.class, this);
  registry.addConverter(DimensionUIResource.class, String.class, this);

  registry.addConverter(Insets.class, String.class, this);
  registry.addConverter(String.class, Insets.class, this);
  registry.addConverter(InsetsUIResource.class, String.class, this);

  registry.addConverter(Point.class, String.class, this);
  registry.addConverter(String.class, Point.class, this);
  
  registry.addConverter(Rectangle.class, String.class, this);
  registry.addConverter(String.class, Rectangle.class, this);
  
  registry.addConverter(Font.class, String.class, this);
  registry.addConverter(FontUIResource.class, String.class, this);
}
 
開發者ID:mstritt,項目名稱:orbit-image-analysis,代碼行數:19,代碼來源:AWTConverters.java

示例6: setAccessibilityFontScale

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
public static void setAccessibilityFontScale( final float scale ) {
    SwingUtilities.invokeLater( new Runnable() {
        public void run() {
            UIDefaults defaults = UIManager.getDefaults();
            Enumeration keys = defaults.keys();
            while ( keys.hasMoreElements() ) {
                Object key = keys.nextElement();
                Object value = defaults.get( key );
                if ( value != null && value instanceof Font ) {
                    UIManager.put( key, null );
                    Font font = UIManager.getFont( key );
                    if ( font != null ) {
                        float size = font.getSize2D();
                        UIManager.put( key, new FontUIResource( font.deriveFont( size * scale ) ) );
                    }
                }
            }
        }
    } );

}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:NaturalSelectionApplication.java

示例7: adjustFont

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 *  Adjust the main font for the GUI (+1 = one size up, -1 = one size down)
 */
public void adjustFont(int adjust)
{
	Object[] objs = UIManager.getLookAndFeel().getDefaults().keySet().toArray();
	for (int i = 0; i < objs.length; i++) {
		if (objs[i].toString().toUpperCase().indexOf(".FONT") != -1) {
			Font font = UIManager.getFont(objs[i]);
			font = font.deriveFont((float) (font.getSize() + adjust));
			UIManager.put(objs[i], new FontUIResource(font));
		}
	}
	SwingUtilities.updateComponentTreeUI(this);
	SwingUtilities.updateComponentTreeUI(choose);
	SwingUtilities.updateComponentTreeUI(options);
	repaint();
}
 
開發者ID:musaeed,項目名稱:Prism-gsoc16,代碼行數:19,代碼來源:GUIPrism.java

示例8: addBasicDefaults

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
@Override
protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
    super.addBasicDefaults(addon, defaults);
    
    Font font = UIManagerExt.getSafeFont("Label.font", new Font("Dialog", Font.PLAIN, 12));
    font = font.deriveFont(Font.BOLD, 13f);
    
    defaults.add(JXCategory.uiClassID, BasicCategoryUI.class.getName());
    defaults.add("Category.font", UIManagerExt.getSafeFont("TextPane.font",
              new FontUIResource("Serif", Font.PLAIN, 12)));
    defaults.add("Category.tipFont", new FontUIResource(font));
    defaults.add("Category.background", new ColorUIResource(Color.WHITE));
    defaults.add("Category.icon",
            LookAndFeel.makeIcon(BasicCategoryUI.class, "resources/dictionary_categories.png"));
    defaults.add("Category.border", new BorderUIResource(
            BorderFactory.createLineBorder(new Color(117, 117, 117))));

  UIManagerExt.addResourceBundle(
          "org.jdesktop.swingx.plaf.basic.resources.Category");
}
 
開發者ID:teddyted,項目名稱:iSeleda,代碼行數:21,代碼來源:CategoryAddon.java

示例9: addWindowsDefaults

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
  super.addWindowsDefaults(addon, defaults);

  Font font = UIManagerExt.getSafeFont("Label.font",
          new Font("Dialog", Font.PLAIN, 12));
  font = font.deriveFont(13f);
  
  defaults.add(JXCategory.uiClassID, WindowsTipOfTheDayUI.class.getName());
  defaults.add("Category.background", new ColorUIResource(Color.GRAY));
  defaults.add("Category.font", new FontUIResource(font));
  defaults.add("Category.icon",
          LookAndFeel.makeIcon(WindowsTipOfTheDayUI.class, "resources/tipoftheday.png"));
  defaults.add("Category.border" ,new BorderUIResource(new WindowsTipOfTheDayUI.TipAreaBorder()));

  UIManagerExt.addResourceBundle(
      "org.jdesktop.swingx.plaf.windows.resources.TipOfTheDay");
}
 
開發者ID:teddyted,項目名稱:iSeleda,代碼行數:22,代碼來源:CategoryAddon.java

示例10: addBasicDefaults

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
@Override
protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
    super.addBasicDefaults(addon, defaults);
    
    Font font = UIManagerExt.getSafeFont("Label.font", new Font("Dialog", Font.PLAIN, 12));
    font = font.deriveFont(Font.BOLD, 13f);
    
    defaults.add(JXTipOfTheDay.uiClassID, BasicTipOfTheDayUI.class.getName());
    defaults.add("TipOfTheDay.font", UIManagerExt.getSafeFont("TextPane.font",
              new FontUIResource("Serif", Font.PLAIN, 12)));
    defaults.add("TipOfTheDay.tipFont", new FontUIResource(font));
    defaults.add("TipOfTheDay.background", new ColorUIResource(Color.WHITE));
    defaults.add("TipOfTheDay.icon",
            LookAndFeel.makeIcon(BasicTipOfTheDayUI.class, "resources/TipOfTheDay24.gif"));
    defaults.add("TipOfTheDay.border", new BorderUIResource(
            BorderFactory.createLineBorder(new Color(117, 117, 117))));

  UIManagerExt.addResourceBundle(
          "org.jdesktop.swingx.plaf.basic.resources.TipOfTheDay");
}
 
開發者ID:teddyted,項目名稱:iSeleda,代碼行數:21,代碼來源:TipOfTheDayAddon.java

示例11: addWindowsDefaults

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
  super.addWindowsDefaults(addon, defaults);

  Font font = UIManagerExt.getSafeFont("Label.font",
          new Font("Dialog", Font.PLAIN, 12));
  font = font.deriveFont(13f);
  
  defaults.add(JXTipOfTheDay.uiClassID, WindowsTipOfTheDayUI.class.getName());
  defaults.add("TipOfTheDay.background", new ColorUIResource(Color.GRAY));
  defaults.add("TipOfTheDay.font", new FontUIResource(font));
  defaults.add("TipOfTheDay.icon",
          LookAndFeel.makeIcon(WindowsTipOfTheDayUI.class, "resources/tipoftheday.png"));
  defaults.add("TipOfTheDay.border" ,new BorderUIResource(new WindowsTipOfTheDayUI.TipAreaBorder()));

  UIManagerExt.addResourceBundle(
      "org.jdesktop.swingx.plaf.windows.resources.TipOfTheDay");
}
 
開發者ID:teddyted,項目名稱:iSeleda,代碼行數:22,代碼來源:TipOfTheDayAddon.java

示例12: setUIDefaultFont

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 * Sets the default font to be used in the GUI.
 * @param fontName The name of the font to be used as default.
 */
public void
setUIDefaultFont(String fontName) {
	if(fontName == null) return;
	
	java.util.Enumeration keys = UIManager.getDefaults().keys();
	while(keys.hasMoreElements()) {
		Object key = keys.nextElement();
		Object value = UIManager.get(key);
		if(value instanceof FontUIResource) {
			Font f = (FontUIResource)value;
			FontUIResource fr =
				new FontUIResource(fontName, f.getStyle(), f.getSize());
			UIManager.put(key, fr);
		}
	}
}
 
開發者ID:lxlxlo,項目名稱:LS-jsampler,代碼行數:21,代碼來源:ViewConfig.java

示例13: getFont

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 * Returns the appropriate font. The font type to return is identified
 * by the specified id.
 *
 * @param id the font type to return
 *
 * @return the correct font
 */
private FontUIResource getFont(int id)
{
  FontUIResource font = null;
  switch (id)
    {
    case CONTROL_TEXT_FONT:
      if (isBoldMetal())
        font = BOLD_CONTROL_TEXT_FONT;
      else
        font = PLAIN_CONTROL_TEXT_FONT;
      break;
    case MENU_TEXT_FONT:
      if (isBoldMetal())
        font = BOLD_MENU_TEXT_FONT;
      else
        font = PLAIN_MENU_TEXT_FONT;
    break;
    // TODO: Add other font types and their mapping here.
    }
  return font;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:30,代碼來源:DefaultMetalTheme.java

示例14: installMacOSXFonts

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
private static void installMacOSXFonts(UIDefaults defaults) {
  String face = "HelveticaNeue-Regular";
  LafManagerImpl.initFontDefaults(defaults, face, 13);
  for (Object key : new HashSet<Object>(defaults.keySet())) {
    Object value = defaults.get(key);
    if (value instanceof FontUIResource) {
      FontUIResource font = (FontUIResource)value;
      if (font.getFamily().equals("Lucida Grande") || font.getFamily().equals("Serif")) {
        if (!key.toString().contains("Menu")) {
          defaults.put(key, new FontUIResource(face, font.getStyle(), font.getSize()));
        }
      }
    }
  }
  FontUIResource uiFont11 = new FontUIResource("HelveticaNeue-Medium", Font.PLAIN, 11);
  defaults.put("TableHeader.font", uiFont11);

  FontUIResource buttonFont = new FontUIResource("HelveticaNeue-Medium", Font.PLAIN, 13);
  defaults.put("Button.font", buttonFont);
  Font menuFont = new FontUIResource("Lucida Grande", Font.PLAIN, 14);
  defaults.put("Menu.font", menuFont);
  defaults.put("MenuItem.font", menuFont);
  defaults.put("MenuItem.acceleratorFont", menuFont);
  defaults.put("PasswordField.font", defaults.getFont("TextField.font"));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:IntelliJLaf.java

示例15: setFont

import javax.swing.plaf.FontUIResource; //導入依賴的package包/類
/**
 * Subclassed to map <code>FontUIResource</code>s to null. If
 * <code>font</code> is null, or a <code>FontUIResource</code>, this
 * has the effect of letting the font of the JTree show
 * through. On the other hand, if <code>font</code> is non-null, and not
 * a <code>FontUIResource</code>, the font becomes <code>font</code>.
 */
public void setFont(Font font) {
    if (font instanceof FontUIResource) {
        font = null;
    }

    super.setFont(font);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:EnhancedTreeCellRenderer.java


注:本文中的javax.swing.plaf.FontUIResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。