本文整理汇总了Java中javax.swing.UIManager.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java UIManager.getFont方法的具体用法?Java UIManager.getFont怎么用?Java UIManager.getFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.UIManager
的用法示例。
在下文中一共展示了UIManager.getFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.swing.UIManager; //导入方法依赖的package包/类
private void init(Action al) {
setOpaque(false);
setBorder(BorderFactory.createEmptyBorder());
setBorderPainted(false);
setFocusPainted(false);
setFocusable(false);
setContentAreaFilled(false);
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
setModel(new Model());
if (null != al) {
addActionListener(al);
setForeground(ColorManager.getDefault().getLinkColor());
} else {
setEnabled(false);
setForeground(ColorManager.getDefault().getDisabledColor());
}
Font font = UIManager.getFont("Tree.font");//NOI18N
if (underlined) {
Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object>();
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
font = font.deriveFont(map);
}
setFont(font);
}
示例2: initStaticUI
import javax.swing.UIManager; //导入方法依赖的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;
}
示例3: getPreferredSize
import javax.swing.UIManager; //导入方法依赖的package包/类
/** Overridden to provide a larger preferred size if the default font
* is larger, for locales that require this. */
public Dimension getPreferredSize() {
//issue 34104, bad sizing/split location for Chinese locales that require
//a larger default font size
Dimension result = super.getPreferredSize();
Font treeFont = UIManager.getFont("Tree.font"); // NOI18N
int fontsize = treeFont != null ? treeFont.getSize() : 11;
if (fontsize > 11) {
int factor = fontsize - 11;
result.height += 15 * factor;
result.width += 50 * factor;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
if (result.height > screen.height) {
result.height = screen.height -30;
}
if (result.width > screen.width) {
result.width = screen.width -30;
}
} else {
result.width += 20;
result.height +=20;
}
return result;
}
示例4: getFontForState
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* Overridden to cause this style to populate itself with data from
* UIDefaults, if necessary. If a value named "font" is not found in
* UIDefaults, then the "defaultFont" font in UIDefaults will be returned
* instead.
*/
@Override protected Font getFontForState(SynthContext ctx) {
Font f = (Font)get(ctx, "font");
if (f == null) f = UIManager.getFont("defaultFont");
// Account for scale
// The key "JComponent.sizeVariant" is used to match Apple's LAF
String scaleKey = (String)ctx.getComponent().getClientProperty(
"JComponent.sizeVariant");
if (scaleKey != null){
if (LARGE_KEY.equals(scaleKey)){
f = f.deriveFont(Math.round(f.getSize2D()*LARGE_SCALE));
} else if (SMALL_KEY.equals(scaleKey)){
f = f.deriveFont(Math.round(f.getSize2D()*SMALL_SCALE));
} else if (MINI_KEY.equals(scaleKey)){
f = f.deriveFont(Math.round(f.getSize2D()*MINI_SCALE));
}
}
return f;
}
示例5: fontButtonActionPerformed
import javax.swing.UIManager; //导入方法依赖的package包/类
private void fontButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fontButtonActionPerformed
PropertyEditor pe = PropertyEditorManager.findEditor(Font.class);
if (pe != null) {
pe.setValue(termOptions.getFont());
DialogDescriptor dd = new DialogDescriptor(pe.getCustomEditor(), FontChooser_title());
String defaultFontString = FontChooser_defaultFont_label();
dd.setOptions(new Object[]{DialogDescriptor.OK_OPTION,
defaultFontString, DialogDescriptor.CANCEL_OPTION}); //NOI18N
DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
if (dd.getValue() == DialogDescriptor.OK_OPTION) {
Font f = (Font) pe.getValue();
termOptions.setFont(f);
applyTermOptions();
} else if (dd.getValue() == defaultFontString) {
Font controlFont = UIManager.getFont("controlFont"); //NOI18N
int fontSize = (controlFont == null) ? 12 : controlFont.getSize();
termOptions.setFont(new Font("monospaced", Font.PLAIN, fontSize)); //NOI18N
}
}
}
示例6: JPQLEditorTopComponent
import javax.swing.UIManager; //导入方法依赖的package包/类
public JPQLEditorTopComponent(JPQLEditorController controller) {
this.controller = controller;
initComponents();
// configure row height
// FIXME there should be a common place to do that
int height = resultsTable.getRowHeight();
Font cellFont = UIManager.getFont("TextField.font");
if (cellFont != null) {
FontMetrics metrics = resultsTable.getFontMetrics(cellFont);
if (metrics != null) {
height = metrics.getHeight() + 2;
}
}
resultsTable.setRowHeight(Math.max(resultsTable.getRowHeight(), height));
puComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
puComboboxActionPerformed();
}
});
this.thisWindowCount = getNextWindowCount();
setName(NbBundle.getMessage(JPQLEditorTopComponent.class, "CTL_JPQLEditorTopComponent") + thisWindowCount);
setToolTipText(NbBundle.getMessage(JPQLEditorTopComponent.class, "HINT_JPQLEditorTopComponent"));
setIcon(ImageUtilities.loadImage(ICON_PATH, true));
sqlToggleButton.setSelected(true);
jpqlEditor.getDocument().addDocumentListener(new JPQLDocumentListener());
((NbEditorDocument) jpqlEditor.getDocument()).runAtomic(new Runnable() {//hack to unlock editor (make modifieble)
@Override
public void run() {
}
});
jpqlEditor.addMouseListener(new JPQLEditorPopupMouseAdapter());
showSQL(NbBundle.getMessage(JPQLEditorTopComponent.class, "BuildHint"));
resultsTable.setDefaultRenderer(Object.class, new ResultTableCellRenderer());
}
示例7: getTitledBorderFont
import javax.swing.UIManager; //导入方法依赖的package包/类
public static Font getTitledBorderFont(TitledBorder tb) {
Font font = tb.getTitleFont();
if (font == null) font = UIManager.getFont("TitledBorder.font"); // NOI18N
if (font == null) font = new JLabel().getFont();
if (font == null) font = UIManager.getFont("Label.font"); // NOI18N
return font;
}
示例8: configureRowHeight
import javax.swing.UIManager; //导入方法依赖的package包/类
public static void configureRowHeight(JTable table) {
int height = table.getRowHeight();
Font cellFont = UIManager.getFont("TextField.font");
if (cellFont != null) {
FontMetrics metrics = table.getFontMetrics(cellFont);
if (metrics != null) {
height = metrics.getHeight() + 2;
}
}
table.setRowHeight(Math.max(table.getRowHeight(), height));
}
示例9: CheckBoxNodeRenderer
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* Constructs a new {@code CheckBoxNodeRenderer}.
*/
public CheckBoxNodeRenderer() {
final Font fontValue = UIManager.getFont("Tree.font");
if (fontValue != null) panel.getLabel().setFont(fontValue);
final Boolean focusPainted =
(Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon");
panel.check.setFocusPainted(focusPainted != null && focusPainted);
selectionForeground = UIManager.getColor("Tree.selectionForeground");
selectionBackground = UIManager.getColor("Tree.selectionBackground");
textForeground = UIManager.getColor("Tree.textForeground");
textBackground = UIManager.getColor("Tree.textBackground");
}
示例10: getTxtFont
import javax.swing.UIManager; //导入方法依赖的package包/类
@Override
protected Font getTxtFont() {
if (isGenericUI) {
Font result = UIManager.getFont("controlFont");
if (result != null) {
return result;
}
}
return super.getTxtFont();
}
示例11: getTxtFont
import javax.swing.UIManager; //导入方法依赖的package包/类
protected Font getTxtFont() {
Font result = UIManager.getFont("controlFont");
if (result != null) {
return result;
}
return super.getTxtFont();
}
示例12: buildStepTitle
import javax.swing.UIManager; //导入方法依赖的package包/类
protected void buildStepTitle()
{
ttlLabel = new JLabel(wizard.getStepDescription(wizard.getAllSteps()[0]));
ttlLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createEmptyBorder(5, 5, 12, 5), BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager
.getColor("textText")))); // NOI18N
ttlPanel = new JPanel()
{
private static final long serialVersionUID = 1L;
public void doLayout()
{
Dimension d = ttlLabel.getPreferredSize();
if (ttlLabel.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
{
ttlLabel.setBounds(getWidth() - d.width, 0, getWidth(), d.height);
}
else
{
ttlLabel.setBounds(0, 0, getWidth(), d.height);
}
}
public Dimension getPreferredSize()
{
return ttlLabel.getPreferredSize();
}
};
ttlPanel.add(ttlLabel);
Font f = ttlLabel.getFont();
if (f == null)
{
f = UIManager.getFont("controlFont"); // NOI18N
}
if (f != null)
{
f = f.deriveFont(Font.BOLD);
ttlLabel.setFont(f);
}
}
示例13: updateStyle
import javax.swing.UIManager; //导入方法依赖的package包/类
protected void updateStyle(){
Font newFont = UIManager.getFont("TextPane.font");
Style defaultStyle = getStyle("default");
StyleConstants.setFontFamily(defaultStyle, newFont.getFamily());
StyleConstants.setFontSize(defaultStyle, newFont.getSize());
StyleConstants.setItalic(defaultStyle, newFont.isItalic());
StyleConstants.setBold(defaultStyle, newFont.isBold());
repaint();
}
示例14: getButtonFont
import javax.swing.UIManager; //导入方法依赖的package包/类
private static Font getButtonFont() {
Font defaultFont = UIManager.getFont("Button.font"); // NOI18N
if(defaultFont != null) {
return defaultFont;
}
return new Font(null, Font.PLAIN, 12);
}
示例15: createHtmlTextToolTip
import javax.swing.UIManager; //导入方法依赖的package包/类
private JEditorPane createHtmlTextToolTip() {
class HtmlTextToolTip extends JEditorPane {
public @Override void setSize(int width, int height) {
Dimension prefSize = getPreferredSize();
if (width >= prefSize.width) {
width = prefSize.width;
} else { // smaller available width
super.setSize(width, 10000); // the height is unimportant
prefSize = getPreferredSize(); // re-read new pref width
}
if (height >= prefSize.height) { // enough height
height = prefSize.height;
}
super.setSize(width, height);
}
@Override
public void setKeymap(Keymap map) {
//#181722: keymaps are shared among components with the same UI
//a default action will be set to the Keymap of this component below,
//so it is necessary to use a Keymap that is not shared with other components
super.setKeymap(addKeymap(null, map));
}
}
JEditorPane tt = new HtmlTextToolTip();
// setup tooltip keybindings
filterBindings(tt.getActionMap());
tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION);
tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME));
tt.getKeymap().setDefaultAction(NO_ACTION);
Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N
if (font != null) {
tt.setFont(font);
}
if (foreColor != null) {
tt.setForeground(foreColor);
}
if (backColor != null) {
tt.setBackground(backColor);
}
tt.setOpaque(true);
tt.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(tt.getForeground()),
BorderFactory.createEmptyBorder(0, 3, 0, 3)
));
tt.setContentType("text/html"); //NOI18N
return tt;
}