本文整理了Java中javax.swing.JComponent.getFont()
方法的一些代码示例,展示了JComponent.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.getFont()
方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:getFont
暂无
代码示例来源:origin: org.netbeans.api/org-openide-awt
searchTextField.setFont(component.getFont());
searchPanel = new SearchPanel(component, isAlwaysShown());
final JLabel lbl;
代码示例来源:origin: nroduit/Weasis
private void updateSize(JComponent parent) {
if (parent != null) {
FontMetrics fmetrics = parent.getFontMetrics(parent.getFont());
iconHeight = fmetrics.getHeight() + 1;
iconWidth = fmetrics.stringWidth(label) + 5;
}
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
/** Generic code to set properties appropriately from any of the renderer
* fetching methods */
private void configureFrom(Object value, JComponent target, boolean selected, boolean leadSelection) {
if (value == null) {
value = "";
}
setText((value == null) ? "" : value.toString());
setSelected(selected);
if (selected) {
setParentFocused(checkFocused(target));
} else {
setParentFocused(false);
}
setEnabled(target.isEnabled());
setLeadSelection(leadSelection);
setFont(target.getFont());
}
代码示例来源:origin: mucommander/mucommander
/**
* Changes the size of the given component's font. Other attributes of the font are left unchanged.
*
* @param comp the component for which to change the font
* @param newSize the new Font size to use, see <code>java.awt.Font</code> for allowed values
* @return the component that was passed, for convenience only
*/
public static JComponent changeSize(JComponent comp, float newSize) {
comp.setFont(comp.getFont().deriveFont(newSize));
return comp;
}
代码示例来源:origin: BaseXdb/basex
/**
* Uses a bold font for the specified component.
* @param comp component
*/
public static void boldFont(final JComponent comp) {
comp.setFont(comp.getFont().deriveFont(Font.BOLD));
}
}
代码示例来源:origin: org.basex/basex
/**
* Resizes a font.
* @param comp component
* @param factor resize factor
*/
public static void resizeFont(final JComponent comp, final float factor) {
final Font f = comp.getFont();
comp.setFont(f.deriveFont(f.getSize() * factor));
}
代码示例来源:origin: mucommander/mucommander
/**
* Changes the style of the given component's font. Other attributes of the font are left unchanged.
*
* @param comp the component for which to change the font
* @param newStyle the new Font style to use, see <code>java.awt.Font</code> for allowed values
* @return the component that was passed, for convenience only
*/
public static JComponent changeStyle(JComponent comp, int newStyle) {
comp.setFont(comp.getFont().deriveFont(newStyle));
return comp;
}
代码示例来源:origin: mucommander/mucommander
/**
* Decreases the size of the given component's font by 2 units. Other attributes of the font are left unchanged.
*
* @param comp the component for which to change the font
* @return the component that was passed, for convenience only
*/
public static JComponent makeMini(JComponent comp) {
changeSize(comp, comp.getFont().getSize()-2);
return comp;
}
}
代码示例来源:origin: tinyMediaManager/tinyMediaManager
/**
* Change the font style of a component
*
* @param comp
* the component for which the font has to be changed
* @param style
* the new style
*/
public static void changeFont(JComponent comp, int style) {
Font font = comp.getFont();
comp.setFont(font.deriveFont(style));
}
代码示例来源:origin: otros-systems/otroslogviewer
public static <T extends JComponent> T fontSize2(T component) {
try {
final int newSize = component.getClass().newInstance().getFont().getSize() * 2;
final Font oldFont = component.getFont();
final Font newFont = new Font(oldFont.getFontName(), oldFont.getStyle(), newSize);
component.setFont(newFont);
} catch (InstantiationException | IllegalAccessException e) {
LOGGER.warn("Can't create new instance of " + component.getClass() + " to get default font size");
}
return component;
}
代码示例来源:origin: BaseXdb/basex
/**
* Resizes a font.
* @param comp component
* @param factor resize factor
*/
public static void resizeFont(final JComponent comp, final float factor) {
final Font f = comp.getFont();
comp.setFont(f.deriveFont(f.getSize() * factor));
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf
public void installUI(JComponent c) {
super.installUI(c);
tip = (JToolTip)c;
Font f = c.getFont();
smallFont = new Font( f.getName(), f.getStyle(), f.getSize() - 2 );
acceleratorDelimiter = UIManager.getString( "MenuItem.acceleratorDelimiter" );
if ( acceleratorDelimiter == null ) { acceleratorDelimiter = "-"; }
}
代码示例来源:origin: org.jspresso.framework/jspresso-swing-application
private int computePixelWidth(JComponent component, int characterLength) {
int charLength = getMaxCharacterLength() + 2;
if (characterLength > 0 && characterLength < getMaxCharacterLength()) {
charLength = characterLength + 2;
}
return component.getFont().getSize() * charLength / 2;
}
代码示例来源:origin: Revivius/nb-darcula
@Override
public void update(Graphics g, JComponent c) {
super.update(g, c);
if (c instanceof JButton) {
JButton b = (JButton) c;
if (b.isDefaultButton() && !SystemInfo.isMac && !c.getFont().isBold()) {
c.setFont(c.getFont().deriveFont(1));
}
}
}
代码示例来源:origin: ganshane/shakey
@Override public void installUI(JComponent c) {
super.installUI(c);
c.setFont( c.getFont().deriveFont(0) );
c.setPreferredSize( new Dimension( c.getPreferredSize().width, 19));
}
}
代码示例来源:origin: com.github.insubstantial/substance
public static void paintText(Graphics g, JComponent component,
Rectangle textRect, String text, int mnemonicIndex,
StateTransitionTracker.ModelStateInfo modelStateInfo,
float textAlpha) {
Color fgColor = getForegroundColor(component, text, modelStateInfo,
textAlpha);
SubstanceTextUtilities.paintText(g, component, textRect, text,
mnemonicIndex, component.getFont(), fgColor, null);
}
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
/**
* Returns the Font of the target component or null if no component installed.
* @return
*/
protected Font getFont() {
return getComponent() != null ? getComponent().getFont() : null;
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu
/**
* Set a bold font.
*/
public static JComponent setBoldFont(JComponent _c) {
Font ft = _c.getFont();
if (ft == null) ft = DEFAULT_FONT;
_c.setFont(deriveFont(ft, Font.BOLD, 0));
return _c;
}
代码示例来源:origin: tinyMediaManager/tinyMediaManager
/**
* Scale the original font of a component by a given factor
*
* @param comp
* the component for which the font has to be changed
* @param scaleFactor
* the scale factor (the result will be rounded to an integer)
*/
public static void changeFont(JComponent comp, double scaleFactor) {
Font font = comp.getFont();
comp.setFont(scale(font, scaleFactor));
}
代码示例来源:origin: com.metsci.glimpse/glimpse-wizard
protected void copySettings( JComponent from, JComponent to )
{
to.setForeground( from.getForeground( ) );
to.setBackground( from.getBackground( ) );
to.setEnabled( from.isEnabled( ) );
to.setFont( from.getFont( ) );
to.setOpaque( from.isOpaque( ) );
}
内容来源于网络,如有侵权,请联系作者删除!