本文整理了Java中javax.swing.JMenuItem.getFont()
方法的一些代码示例,展示了JMenuItem.getFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.getFont()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:getFont
暂无
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction(jsDoc = FONT_JSDOC)
@Override
public Font getFont() {
return super.getFont();
}
代码示例来源:origin: stackoverflow.com
private JMenuItem newItem(String text, String iconPath) {
JMenuItem myMenuItem;
if (iconPath == null || iconPath.isEmpty()) {
myMenuItem = new JMenuItem(text);
myMenuItem.setPreferredSize(new Dimension(myMenuItem.getFontMetrics(myMenuItem.getFont()).stringWidth(text), 20));
} else {
ImageIcon icon = new ImageIcon(iconPath);
myMenuItem = new JMenuItem(text, icon);
myMenuItem.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
}
return myMenuItem;
}
代码示例来源:origin: com.github.insubstantial/substance
public static void paintMenuItemText(Graphics g, JMenuItem menuItem,
Rectangle textRect, String text, int mnemonicIndex,
StateTransitionTracker.ModelStateInfo modelStateInfo,
float textAlpha) {
Color fgColor = getMenuComponentForegroundColor(menuItem, text,
modelStateInfo, textAlpha);
SubstanceTextUtilities.paintText(g, menuItem, textRect, text,
mnemonicIndex, menuItem.getFont(), fgColor, null);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
FontMetrics fm=item.getFontMetrics(item.getFont());
int maxTextWidth=fm.stringWidth(item.getText());
fm=currItem.getFontMetrics(currItem.getFont());
maxTextWidth=Math.max(maxTextWidth, fm.stringWidth(currItem.getText()));
fm=currItem.getFontMetrics(currItem.getFont());
maxTextWidth=Math.max(maxTextWidth, fm.stringWidth(currItem.getText()));
代码示例来源:origin: org.java.net.substance/substance
public static void paintMenuItemText(Graphics g, JMenuItem menuItem,
Rectangle textRect, String text, int mnemonicIndex,
StateTransitionTracker.ModelStateInfo modelStateInfo,
float textAlpha) {
Color fgColor = getMenuItemForegroundColor(menuItem, text,
modelStateInfo, textAlpha);
SubstanceTextUtilities.paintText(g, menuItem, textRect, text,
mnemonicIndex, menuItem.getFont(), fgColor, null);
}
代码示例来源:origin: com.github.insubstantial/substance
FontMetrics fm = menuItem.getFontMetrics(menuItem.getFont());
FontMetrics fmAccel = menuItem.getFontMetrics(acceleratorFont);
代码示例来源:origin: com.dorkbox/SystemTray
SwingMenuItemStatus(final SwingMenu parent, final Entry entry) {
this.parent = parent;
if (SystemTray.SWING_UI != null) {
_native.setUI(SystemTray.SWING_UI.getItemUI(_native, entry));
}
_native.setHorizontalAlignment(SwingConstants.LEFT);
// status is ALWAYS at 0 index...
parent._native.add(_native, 0);
Font font = _native.getFont();
Font font1 = font.deriveFont(Font.BOLD);
_native.setFont(font1);
// this makes sure it can't be selected
_native.setEnabled(false);
}
代码示例来源:origin: org.java.net.substance/substance
FontMetrics fm = menuItem.getFontMetrics(menuItem.getFont());
FontMetrics fmAccel = menuItem.getFontMetrics(acceleratorFont);
代码示例来源:origin: com.google.code.findbugs/findbugs
item.setFont(item.getFont().deriveFont(Driver.getFontSize()));
return item;
代码示例来源:origin: com.jidesoft/jide-oss
Font font = b.getFont();
FontMetrics fm = b.getFontMetrics(font);
FontMetrics fmAccel = b.getFontMetrics(acceleratorFont);
代码示例来源:origin: lycying/c2d-engine
mntmAddBoxFixture.setFont(new Font(mntmAddBoxFixture.getFont().getName(), Font.PLAIN, 24));
popupMenu.add(mntmAddBoxFixture);
mntmAddBoxFixture.addActionListener(new ActionListener() {
mntmAddCircleFixture.setFont(new Font(mntmAddCircleFixture.getFont().getName(), Font.PLAIN, 24));
popupMenu.add(mntmAddCircleFixture);
mntmAddCircleFixture.addActionListener(new ActionListener() {
mntmAddPolygonFixture.setFont(new Font(mntmAddPolygonFixture.getFont().getName(), Font.PLAIN, 24));
popupMenu.add(mntmAddPolygonFixture);
mntmAddPolygonFixture.addActionListener(new ActionListener() {
mntmAddBody.setFont(new Font(mntmAddBody.getFont().getName(), Font.PLAIN, 24));
popupMenu.add(mntmAddBody);
mntmAddBody.addActionListener(new ActionListener() {
mntmDelete.setFont(new Font(mntmDelete.getFont().getName(), Font.PLAIN, 24));
mntmDelete.setIcon(new ImageIcon(Box2dFunctionPanel.class.getResource("/info/u250/c2d/box2deditor/ui/res/remove-icon.png")));
popupMenu.add(mntmDelete);
代码示例来源:origin: com.fifesoft.rtext/fife.common
private void addItemsFor(File dir, ScrollableJPopupMenu popup) {
if (dir!=null) {
File[] children = dir.listFiles(File::isDirectory);
// children can be null e.g. on Windows, when examining an
// empty DVD/blu-ray drive
int count = children!=null ? children.length : 0;
for (int i=0; i<count; i++) {
dir = children[i];
Icon icon = getIcon(dir);
JMenuItem item = new JMenuItem(dir.getName(), icon);
if (isAncestorOfShownLocation(dir)) {
Font font = item.getFont();
font = font.deriveFont(Font.BOLD);
item.setFont(font);
}
item.putClientProperty(PROPERTY_LOCATION, dir);
item.addActionListener(this);
popup.addComponent(item);
}
}
else { // roots
List<JMenuItem> roots = getRoots();
for (JMenuItem root : roots) {
popup.addComponent(root);
}
}
}
代码示例来源:origin: org.biojava.thirdparty/forester
customizeJMenuItem( _open_item );
_open_item
.setFont( new Font( _open_item.getFont().getFontName(), Font.BOLD, _open_item.getFont().getSize() + 4 ) );
customizeJMenuItem( _open_url_item );
for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {
代码示例来源:origin: com.dorkbox/SystemTray
SwingMenuItemCheckbox(final SwingMenu parent, final Entry entry) {
super(parent, entry);
if (checkedIcon == null) {
try {
JMenuItem jMenuItem = new JMenuItem();
// do the same modifications that would also happen (if specified) for the actual displayed menu items
if (SystemTray.SWING_UI != null) {
jMenuItem.setUI(SystemTray.SWING_UI.getItemUI(jMenuItem, null));
}
// Having the checkmark size the same size as the letter X is a reasonably nice size.
int size = FontUtil.getFontHeight(jMenuItem.getFont(), "X");
// this is the largest size of an image used in a JMenuItem, before the size of the JMenuItem is forced to be larger
int menuImageSize = SystemTray.get()
.getMenuImageSize();
String checkmarkPath;
if (SystemTray.SWING_UI != null) {
checkmarkPath = SystemTray.SWING_UI.getCheckMarkIcon(jMenuItem.getForeground(), size, menuImageSize);
} else {
checkmarkPath = HeavyCheckMark.get(jMenuItem.getForeground(), size, menuImageSize);
}
checkedIcon = new ImageIcon(checkmarkPath);
} catch(Exception e) {
SystemTray.logger.error("Error creating check-mark image.", e);
}
}
}
代码示例来源:origin: blurpy/kouchat
privchatMI.setMnemonic(keyCode(swingMessages.getMessage("swing.userList.rightClickPopup.menu.privateChat.mnemonic")));
privchatMI.addActionListener(this);
privchatMI.setFont(privchatMI.getFont().deriveFont(Font.BOLD)); // default menu item
userMenu.add(infoMI);
userMenu.add(sendfileMI);
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
if (!AbstractLookAndFeel.getTheme().isDarkTexture()) {
super.paintText(g, menuItem, textRect, text);
return;
}
ButtonModel model = menuItem.getModel();
FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
int mnemIndex = menuItem.getDisplayedMnemonicIndex();
if (!menuItem.isArmed()) {
g.setColor(Color.black);
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
}
if (!model.isEnabled()) {
// *** paint the text disabled
g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40));
} else {
// *** paint the text normally
if (menuItem.isArmed()) {
g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
} else {
Color foreColor = menuItem.getForeground();
if (foreColor instanceof UIResource) {
foreColor = AbstractLookAndFeel.getMenuForegroundColor();
}
g.setColor(foreColor);
}
}
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
if (!AbstractLookAndFeel.getTheme().isDarkTexture()) {
super.paintText(g, menuItem, textRect, text);
return;
}
ButtonModel model = menuItem.getModel();
FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
int mnemIndex = menuItem.getDisplayedMnemonicIndex();
if (!menuItem.isArmed()) {
g.setColor(Color.black);
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
}
if (!model.isEnabled()) {
// *** paint the text disabled
g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40));
} else {
// *** paint the text normally
if (menuItem.isArmed()) {
g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
} else {
Color foreColor = menuItem.getForeground();
if (foreColor instanceof UIResource) {
foreColor = AbstractLookAndFeel.getMenuForegroundColor();
}
g.setColor(foreColor);
}
}
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
代码示例来源:origin: com.jtattoo/JTattoo
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
if (!AbstractLookAndFeel.getTheme().isDarkTexture()) {
super.paintText(g, menuItem, textRect, text);
return;
}
ButtonModel model = menuItem.getModel();
FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
int mnemIndex = menuItem.getDisplayedMnemonicIndex();
if (!menuItem.isArmed()) {
g.setColor(Color.black);
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() - 1);
}
if (!model.isEnabled()) {
// *** paint the text disabled
g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40));
} else {
// *** paint the text normally
if (menuItem.isArmed()) {
g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
} else {
Color foreColor = menuItem.getForeground();
if (foreColor instanceof UIResource) {
foreColor = AbstractLookAndFeel.getMenuForegroundColor();
}
g.setColor(foreColor);
}
}
JTattooUtilities.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
}
代码示例来源:origin: com.jtattoo/JTattoo
FontMetrics fm = JTattooUtilities.getFontMetrics(menuItem, g, menuItem.getFont());
int mnemIndex = menuItem.getDisplayedMnemonicIndex();
if (!model.isEnabled()) {
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
Font font= b.getFont();
FontMetrics fm= b.getToolkit().getFontMetrics(font);
FontMetrics fmAccel= b.getToolkit().getFontMetrics(acceleratorFont);
内容来源于网络,如有侵权,请联系作者删除!