当前位置: 首页>>代码示例>>Java>>正文


Java Component.getFont方法代码示例

本文整理汇总了Java中java.awt.Component.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getFont方法的具体用法?Java Component.getFont怎么用?Java Component.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Component的用法示例。


在下文中一共展示了Component.getFont方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareRenderer

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component prepareRenderer(TableCellRenderer renderer,
                                 int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    if (column == VALUE_COLUMN && isAttributeViewable(row, VALUE_COLUMN)) {
        comp.setFont(boldFont);
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:XTable.java

示例2: initStaticUI

import java.awt.Component; //导入方法依赖的package包/类
private static void initStaticUI(Component c, JTableHeader header) {
    painter = new LabelRenderer(true);
    
    Color color = c.getForeground();
    if (color == null) color = header.getForeground();
    if (color == null) color = UIManager.getColor("TableHeader.foreground"); // NOI18N
    if (color != null) painter.setForeground(color);
    Font font = c.getFont();
    if (font == null) font = header.getFont();
    if (font == null) font = UIManager.getFont("TableHeader.font"); // NOI18N
    if (font != null) painter.setFont(font);
    
    if (UIUtils.isWindowsXPLookAndFeel()) Y_LAF_OFFSET = 1;
    else if (UIUtils.isNimbusLookAndFeel()) Y_LAF_OFFSET = -1;
    else Y_LAF_OFFSET = 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TimelineHeaderRenderer.java

示例3: prepareRenderer

import java.awt.Component; //导入方法依赖的package包/类
public Component prepareRenderer(TableCellRenderer renderer,
        int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    Object o = ((DefaultTableModel) getModel()).getValueAt(row, column);
    if (column == 0) {
        String key = o.toString();
        renderKey(key, comp);
    } else {
        if (isClickableElement(o)) {
            comp.setFont(boldFont);
        } else {
            comp.setFont(normalFont);
        }
    }

    return comp;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:XOpenTypeViewer.java

示例4: setEmphasizedFont

import java.awt.Component; //导入方法依赖的package包/类
void setEmphasizedFont(Component label, boolean emphasized) {
    Font basefont = label.getFont();
    if(emphasized) {
        label.setFont(basefont.deriveFont(Font.ITALIC));
    } else {
        label.setFont(basefont.deriveFont(Font.PLAIN));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:JFXRunPanel.java

示例5: prepareRenderer

import java.awt.Component; //导入方法依赖的package包/类
@Override
public synchronized Component prepareRenderer(
        TableCellRenderer renderer, int row, int column) {
    //In case we have a repaint thread that is in the process of
    //repainting an obsolete table, just ignore the call.
    //It can happen when MBean selection is switched at a very quick rate
    if (row >= getRowCount()) {
        return null;
    }

    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    UserDataCell cell = getUserDataCell(row, 2);
    if (column == 2 && cell != null) {
        comp.setFont(boldFont);
        int size = cell.getHeight();
        if (size > 0) {
            if (getRowHeight(row) != size) {
                setRowHeight(row, size);
            }
        }
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:XMBeanNotifications.java

示例6: renderKey

import java.awt.Component; //导入方法依赖的package包/类
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        italicFont = normalFont.deriveFont(Font.ITALIC);
    }
    for(Object k : type.getIndexNames()) {
        if(key.equals(k))
            comp.setFont(italicFont);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:XOpenTypeViewer.java

示例7: getFont

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Returns default font of the titled border.
 * @return default font of the titled border
 * @param c the component
 */
protected Font getFont(Component c) {
    Font font = getTitleFont();
    if (font != null) {
        return font;
    }
    if (c != null) {
        font = c.getFont();
        if (font != null) {
            return font;
        }
    }
    return new Font(Font.DIALOG, Font.PLAIN, 12);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TitledBorder.java

示例8: updateMetrics

import java.awt.Component; //导入方法依赖的package包/类
final void updateMetrics() {
	Component host = getContainer();
	Font f = host.getFont();
	metrics = host.getFontMetrics(f); // Metrics for the default font.
	tabSize = getTabSize() * metrics.charWidth('m');
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:7,代码来源:WrappedSyntaxView.java

示例9: doRender

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Run the render method of the given component.
 * 
 * @param comp
 */
private void doRender(Component comp) {
	if (rendered.contains(System.identityHashCode(comp))) {
		return;
	}
	rendered.add(System.identityHashCode(comp));
	if (comp instanceof Container) {
		Container cont = (Container) comp;
		for (Component comp2 : cont.getComponents()) {
			doRender(comp2);
		}
	}

	float[] scale = getScalef();

	Component originalComponent = null;
	try {
		originalComponent = deserializeObject(JComponent.class, originalComps.get(System.identityHashCode(comp)));
	} catch (ClassNotFoundException | IOException e) {
		e.printStackTrace();
	}

	if (originalComponent != null) {
		// Bounds
		if (isWindowOptionEnabled(WindowOptions.SCALE_COMPONENTS)) {
			Rectangle original = originalComponent.getBounds();
			int newX = (int) (original.getX() * scale[0]);
			int newY = (int) (original.getY() * scale[1]);
			int newW = (int) (original.getWidth() * scale[0]);
			int newH = (int) (original.getHeight() * scale[1]);
			comp.setBounds(newX, newY, newW, newH);
		}

		// Fonts
		if (isWindowOptionEnabled(WindowOptions.SCALE_FONTS)) {
			if (comp.getFont() != null && originalComponent.getFont() != null) {
				Font font = comp.getFont();
				Font newFont = font.deriveFont(font.getStyle(),
						getSuggestedFontSize(originalComponent.getFont().getSize()));
				comp.setFont(newFont);
			}
		}

		// Images
		if (isWindowOptionEnabled(WindowOptions.SCALE_IMAGES)) {
			if (comp instanceof JLabel) {
				JLabel label = (JLabel) comp;
				JLabel orig = (JLabel) originalComponent;
				label.setIcon(getScaledImageIcon(orig));
			}
		}
	}
}
 
开发者ID:Cyphereion,项目名称:Java-Swing-Helper,代码行数:58,代码来源:SwingWindow.java

示例10: setPlain

import java.awt.Component; //导入方法依赖的package包/类
/**
 * It sets the font of the given component to the "Dialog" series and
 * with the plain style.
 *
 * @param component The component whose font will be set.
 *
 * @see #setBold(Component)
 * @see #setItalic(Component)
 * @see #setBoldItalic(Component)
 */
static public void setPlain(Component component) {
    ArgumentChecking.notNull(component, "component");
    
    Font font = component.getFont();
    int style = Font.PLAIN;
    int size = font.getSize();
    Font newFont = new Font(FONT_NAME, style, size);
    component.setFont(newFont);
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:20,代码来源:GUIUtilities.java

示例11: setBold

import java.awt.Component; //导入方法依赖的package包/类
/**
 * It sets the font of the given component to the "Dialog" series and
 * with the bold style.
 *
 * @param component The component whose font will be set.
 *
 * @see #setPlain(Component)
 * @see #setItalic(Component)
 * @see #setBoldItalic(Component)
 */
static public void setBold(Component component) {
    ArgumentChecking.notNull(component, "component");
    
    Font font = component.getFont();
    int style = Font.BOLD;
    int size = font.getSize();
    Font newFont = new Font(FONT_NAME, style, size);
    component.setFont(newFont);
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:20,代码来源:GUIUtilities.java

示例12: setItalic

import java.awt.Component; //导入方法依赖的package包/类
/**
 * It sets the font of the given component to the "Dialog" series and
 * with the italic style.
 *
 * @param component The component whose font will be set.
 *
 * @see #setPlain(Component)
 * @see #setBold(Component)
 * @see #setBoldItalic(Component)
 */
static public void setItalic(Component component) {
    ArgumentChecking.notNull(component, "component");
    
    Font font = component.getFont();
    int style = Font.ITALIC;
    int size = font.getSize();
    Font newFont = new Font(FONT_NAME, style, size);
    component.setFont(newFont);
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:20,代码来源:GUIUtilities.java

示例13: setBoldItalic

import java.awt.Component; //导入方法依赖的package包/类
/**
 * It sets the font of the given component to the "Dialog" series and
 * with the bold/italic style.
 *
 * @param component The component whose font will be set.
 *
 * @see #setPlain(Component)
 * @see #setBold(Component)
 * @see #setItalic(Component)
 */
static public void setBoldItalic(Component component) {
    ArgumentChecking.notNull(component, "component");
    
    Font font = component.getFont();
    int style = Font.ITALIC | Font.BOLD;
    int size = font.getSize();
    Font newFont = new Font(FONT_NAME, style, size);
    component.setFont(newFont);
}
 
开发者ID:vimerzhao,项目名称:gchisto,代码行数:20,代码来源:GUIUtilities.java


注:本文中的java.awt.Component.getFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。