Java Code Examples for javax.swing.JComponent.setFont()

The following are Jave code examples for showing how to use setFont() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PTEAssistant   File: UserTableHeaderCellRenderer.java   View Source Code Vote up 6 votes
@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;
}
 
Example 2
Project: Neukoelln_SER316   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 3
Project: incubator-netbeans   File: TaskPanel.java   View Source Code Vote up 5 votes
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));
        }
    }
}
 
Example 4
Project: incubator-netbeans   File: IssuePanel.java   View Source Code Vote up 5 votes
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));
        }
    }
}
 
Example 5
Project: rapidminer   File: DefaultPropertyKeyRenderer.java   View Source Code Vote up 5 votes
@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;
}
 
Example 6
Project: rapidminer   File: OnboardingDialog.java   View Source Code Vote up 5 votes
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);
    }

}
 
Example 7
Project: SER316-Dresden   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 8
Project: SER316-Munich   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 9
Project: SER316-Ingolstadt   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 10
Project: Wilmersdorf_SER316   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 11
Project: Cognizant-Intelligent-Test-Scripter   File: StepRenderer.java   View Source Code Vote up 5 votes
@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));
    }
}
 
Example 12
Project: openjdk-jdk10   File: bug8132119.java   View Source Code Vote up 5 votes
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;
}
 
Example 13
Project: Reinickendorf_SER316   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 14
Project: Dahlem_SER316   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 15
Project: SER316-Aachen   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
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));
}
 
Example 16
Project: incubator-netbeans   File: AttachmentsPanel.java   View Source Code Vote up 4 votes
protected void strikeThrough(JComponent cmp) {
    Map attributes = cmp.getFont().getAttributes();
    attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
    cmp.setFont(cmp.getFont().deriveFont(attributes));
}
 
Example 17
Project: incubator-netbeans   File: Coloring.java   View Source Code Vote up 4 votes
/** 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);
                }
            }
        }
    }
}
 
Example 18
Project: incubator-netbeans   File: MarginViewportUI.java   View Source Code Vote up 4 votes
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);
    }
}
 
Example 19
Project: JuggleMasterPro   File: ColorChooserDropDownJButton.java   View Source Code Vote up 4 votes
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));
}