本文整理汇总了Java中javax.swing.JComponent.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.setFont方法的具体用法?Java JComponent.setFont怎么用?Java JComponent.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.setFont方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellRendererComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
String valueStr = (String) value;
JLabel label = new JLabel(valueStr);
label.setHorizontalAlignment(SwingConstants.CENTER);
selectBox.setHorizontalAlignment(SwingConstants.CENTER);
selectBox.setBorderPainted(true);
JComponent component = (column == 0) ? selectBox : label;
component.setForeground(tableHeader.getForeground());
component.setBackground(tableHeader.getBackground());
component.setFont(tableHeader.getFont());
component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return component;
}
示例2: applyFont
import javax.swing.JComponent; //导入方法依赖的package包/类
private void applyFont(Task t, JComponent c) {
if ((t.getStatus(CurrentDate.get()) == Task.ACTIVE)
|| (t.getStatus(CurrentDate.get()) == Task.DEADLINE))
c.setFont(c.getFont().deriveFont(Font.BOLD));
else
c.setFont(c.getFont().deriveFont(Font.PLAIN));
}
示例3: updateFieldDecorations
import javax.swing.JComponent; //导入方法依赖的package包/类
private void updateFieldDecorations (String key, JComponent fieldLabel) {
boolean fieldDirty = unsavedFields.contains(key);
if (fieldLabel != null) {
if (fieldDirty) {
fieldLabel.setFont(fieldLabel.getFont().deriveFont(fieldLabel.getFont().getStyle() | Font.BOLD));
} else {
fieldLabel.setFont(fieldLabel.getFont().deriveFont(fieldLabel.getFont().getStyle() & ~Font.BOLD));
}
}
}
示例4: getTableCellEditorComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) {
JComponent c = (JComponent) super.getTableCellEditorComponent(table, value, selected, row, column);
if (!type.isOptional() && (type.getDefaultValue() == null)) {
c.setFont(c.getFont().deriveFont(Font.BOLD, c.getFont().getSize()));
}
if (selected) {
c.setBackground(SwingTools.LIGHTEST_BLUE);
} else {
c.setBackground(Color.WHITE);
}
return c;
}
示例5: decorateJComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
private void decorateJComponent(JComponent component) {
String prop = (String)component.getClientProperty("com.rapidminer.ui.label.type");
if("header".equals(prop)) {
component.setFont(OPEN_SANS_LIGHT_28);
component.setForeground(SwingTools.RAPIDMINER_ORANGE);
} else if("bold".equals(prop)) {
component.setFont(OPEN_SANS_SEMIBOLD_14);
component.setForeground(Color.DARK_GRAY);
} else if("normal".equals(prop)) {
component.setFont(OPEN_SANS_LIGHT_14);
component.setForeground(Color.DARK_GRAY);
} else if("large".equals(prop)) {
component.setFont(OPEN_SANS_SEMIBOLD_16);
component.setForeground(Color.DARK_GRAY);
}
prop = (String)component.getClientProperty("com.rapidminer.ui.button.type");
if("cfa".equals(prop)) {
component.setFont(OPEN_SANS_SEMIBOLD_14);
component.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
} else if("normal".equals(prop)) {
component.setFont(OPEN_SANS_LIGHT_14);
component.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
component.setMinimumSize(new Dimension(175, component.getPreferredSize().height));
component.setPreferredSize(new Dimension(175, component.getPreferredSize().height));
}
prop = (String)component.getClientProperty("com.rapidmniner.ui.link_button.id");
if(prop != null && component instanceof LinkButton) {
((LinkButton)component).setText(this.generateHTML(prop));
}
Color foregroundColor = (Color)component.getClientProperty("com.rapidminer.ui.label.foreground");
if(foregroundColor != null) {
component.setForeground(foregroundColor);
}
}
示例6: render
import javax.swing.JComponent; //导入方法依赖的package包/类
@Override
public void render(JComponent comp, TestStep step, Object value) {
comp.setForeground(getColor(step));
if (step.isCommented() || step.hasBreakPoint()) {
comp.setFont(new Font("Default", Font.BOLD, 11));
}
}
示例7: createComponent
import javax.swing.JComponent; //导入方法依赖的package包/类
private static JComponent createComponent(String str) {
JComponent comp = new JLabel(str);
comp.setSize(WIDTH, HEIGHT);
comp.putClientProperty(TextAttribute.NUMERIC_SHAPING, NUMERIC_SHAPER);
comp.setFont(getFont());
return comp;
}
示例8: strikeThrough
import javax.swing.JComponent; //导入方法依赖的package包/类
protected void strikeThrough(JComponent cmp) {
Map attributes = cmp.getFont().getAttributes();
attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
cmp.setFont(cmp.getFont().deriveFont(attributes));
}
示例9: apply
import javax.swing.JComponent; //导入方法依赖的package包/类
/** Apply this coloring to component colors/font.
* The underline and strikeThrough line colors have no effect here.
*/
public void apply(JComponent c) {
// Possibly change font
if (font != null) {
if (fontMode == FONT_MODE_DEFAULT) {
c.setFont(font);
} else { // non-default font-mode
Font origFont = c.getFont();
if (origFont != null) {
synchronized (cacheLock) {
Font f = (Font)fontAndForeColorCache.get(origFont);
if (f == null) {
f = modifyFont(origFont);
fontAndForeColorCache.put(origFont, f);
}
c.setFont(f);
}
}
}
}
// Possibly change fore-color
if (foreColor != null) {
if (!hasAlpha(foreColor)) {
c.setForeground(foreColor);
} else { // non-default fore color-mode
Color origForeColor = c.getForeground();
if (origForeColor != null) {
synchronized (cacheLock) {
Color fc = (Color)fontAndForeColorCache.get(origForeColor);
if (fc == null) {
fc = modifyForeColor(origForeColor);
fontAndForeColorCache.put(origForeColor, fc);
}
c.setForeground(fc);
}
}
}
}
// Possibly change back-color
if (backColor != null) {
if (!hasAlpha(backColor)) {
c.setBackground(backColor);
} else { // non-default back color-mode
Color origBackColor = c.getBackground();
if (origBackColor != null) {
synchronized (cacheLock) {
Color bc = (Color)backColorCache.get(origBackColor);
if (bc == null) {
bc = modifyBackColor(origBackColor);
backColorCache.put(origBackColor, bc);
}
c.setBackground(bc);
}
}
}
}
}
示例10: installUI
import javax.swing.JComponent; //导入方法依赖的package包/类
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);
}
}
示例11: setBallsColorsPopUp
import javax.swing.JComponent; //导入方法依赖的package包/类
final private void setBallsColorsPopUp() {
final JPanel objLjPanel = new JPanel(new GridBagLayout());
objLjPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
objLjPanel.setOpaque(true);
final ExtendedGridBagConstraints objLextendedGridBagConstraints =
new ExtendedGridBagConstraints( GridBagConstraints.RELATIVE,
0,
1,
1,
GridBagConstraints.CENTER,
0,
0);
for (byte bytLshadeIndex = 0; bytLshadeIndex < BallsColors.bytS_BALLS_COLORS_SHADES_NUMBER; ++bytLshadeIndex) {
for (byte bytLcolorLetterIndex = Constants.bytS_UNCLASS_NO_VALUE; bytLcolorLetterIndex <= BallsColors.bytS_BALLS_COLORS_LETTERS_NUMBER; ++bytLcolorLetterIndex) {
objLextendedGridBagConstraints.setGridLocation(GridBagConstraints.RELATIVE, BallsColors.bytS_BALLS_COLORS_SHADES_NUMBER
- bytLshadeIndex);
switch (bytLshadeIndex) {
case 0:
case BallsColors.bytS_BALLS_COLORS_SHADE_MAXIMUM_VALUE:
final ExtendedJLabel objLjLabel =
new ExtendedJLabel( this.objGcontrolJFrame,
bytLcolorLetterIndex != Constants.bytS_UNCLASS_NO_VALUE
&& bytLcolorLetterIndex != BallsColors.bytS_BALLS_COLORS_LETTERS_NUMBER
? Character.toString(BallsColors.chrS_BALLS_COLORS_LETTER_A[bytLcolorLetterIndex])
: null);
if (0 <= bytLcolorLetterIndex && bytLcolorLetterIndex < BallsColors.bytS_BALLS_COLORS_LETTERS_NUMBER) {
objLjLabel.setToolTipText(Preferences.getGlobalBooleanPreference(Constants.bytS_BOOLEAN_GLOBAL_BUTTONS_TOOLTIPS)
? BallsColors.strS_BALLS_COLORS_LETTER_A[bytLcolorLetterIndex]
: null);
}
objLjLabel.setFont(objLjLabel.getFont().deriveFont(8.0F));
objLjPanel.add(objLjLabel, objLextendedGridBagConstraints);
break;
default:
final boolean bolLrowHeader =
bytLcolorLetterIndex == Constants.bytS_UNCLASS_NO_VALUE
|| bytLcolorLetterIndex == BallsColors.bytS_BALLS_COLORS_LETTERS_NUMBER;
final JComponent objLjComponent =
bolLrowHeader
? new ExtendedJLabel( this.objGcontrolJFrame,
Byte.toString(bytLshadeIndex))
: new BallColorJButton( this.objGcontrolJFrame,
BallsColors.getLogicalColorValue( bytLcolorLetterIndex,
bytLshadeIndex,
true));
objLjComponent.setFont(this.objGcontrolJFrame.getFont().deriveFont(8.0F));
objLjComponent.setOpaque(true);
if (bolLrowHeader) {
objLextendedGridBagConstraints.setMargins( 0,
0,
bytLcolorLetterIndex == Constants.bytS_UNCLASS_NO_VALUE ? 0 : 3,
bytLcolorLetterIndex == Constants.bytS_UNCLASS_NO_VALUE ? 3 : 0);
}
objLjPanel.add(objLjComponent, objLextendedGridBagConstraints);
if (bolLrowHeader) {
objLextendedGridBagConstraints.setMargins(0, 0, 0, 0);
}
}
}
}
this.objGjWindow.setBackground(Constants.objS_PEN_COLORS_LIGHT_YELLOW_COLOR);
this.objGjWindow.setLayout(new GridBagLayout());
this.objGjWindow.add(objLjPanel, new ExtendedGridBagConstraints(1, 1, 1, 1, GridBagConstraints.CENTER, 5, 5, 0, 0, 0, 0));
}