本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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 ) ) );
}
}
}
}
} );
}
示例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();
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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);
}
}
}
示例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;
}
示例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"));
}
示例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);
}