本文整理了Java中javax.swing.JMenuItem.setFont()
方法的一些代码示例,展示了JMenuItem.setFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.setFont()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:setFont
暂无
代码示例来源:origin: Exslims/MercuryTrade
public JMenuItem getMenuItem(String text) {
JMenuItem menuItem = new JMenuItem(text);
menuItem.setFont(REGULAR_FONT.deriveFont(scale * 16f));
menuItem.setForeground(AppThemeColor.TEXT_DEFAULT);
return menuItem;
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction
@Override
public void setFont(Font aFont) {
super.setFont(aFont);
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/** Adds a menu item to the popup menu. */
public void add(JMenuItem item) {
getPopupMenu().add(item);
item.setFont(itemFont);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu getPopupMenu() {
if (memoryResPopupMenu == null) {
memoryResPopupMenu = new JPopupMenu();
if (GoToSource.isAvailable()) {
Font boldfont = memoryResPopupMenu.getFont().deriveFont(Font.BOLD);
popupShowSource = new JMenuItem();
popupShowSource.setFont(boldfont);
popupShowSource.setText(GO_SOURCE_POPUP_ITEM_NAME);
memoryResPopupMenu.add(popupShowSource);
popupShowSource.addActionListener(this);
}
}
return memoryResPopupMenu;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu getPopupMenu() {
if (popup == null) {
popup = new JPopupMenu();
if (GoToSource.isAvailable()) {
Font boldfont = popup.getFont().deriveFont(Font.BOLD);
popupShowSource = new JMenuItem();
popupShowSource.setText(GO_SOURCE_POPUP_ITEM);
popupShowSource.setFont(boldfont);
popup.add(popupShowSource);
popupShowSource.addActionListener(this);
}
}
return popup;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu getPopupMenu() {
if (memoryResPopupMenu == null) {
memoryResPopupMenu = new JPopupMenu();
if (GoToSource.isAvailable()) {
Font boldfont = memoryResPopupMenu.getFont().deriveFont(Font.BOLD);
popupShowSource = new JMenuItem();
popupShowSource.setFont(boldfont);
popupShowSource.setText(GO_SOURCE_POPUP_ITEM_NAME);
memoryResPopupMenu.add(popupShowSource);
popupShowSource.addActionListener(this);
}
}
return memoryResPopupMenu;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu initPopupMenu() {
JPopupMenu popup = new JPopupMenu();
Font boldfont = popup.getFont().deriveFont(Font.BOLD);
if (GoToSource.isAvailable()) {
popupShowSource = new JMenuItem();
popupShowSource.setFont(boldfont);
popupShowSource.setText(GO_SOURCE_POPUP_ITEM);
popupShowSource.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (treePath != null) {
performDefaultAction(treePath);
}
}
});
popup.add(popupShowSource);
}
return popup;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu createPopupMenu() {
JPopupMenu popup = new JPopupMenu();
if (GoToSource.isAvailable()) popupShowSource = new JMenuItem();
popupAddToRoots = new JMenuItem();
Font boldfont = popup.getFont().deriveFont(Font.BOLD);
if (popupShowSource != null) {
popupShowSource.setFont(boldfont);
popupShowSource.setText(GO_TO_SOURCE_POPUP_ITEM);
popup.add(popupShowSource);
popup.addSeparator();
}
popupAddToRoots.setText(ADD_ROOT_METHOD_POPUP_ITEM);
popup.add(popupAddToRoots);
ActionListener menuListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
menuActionPerformed(evt);
}
};
if (popupShowSource != null) popupShowSource.addActionListener(menuListener);
popupAddToRoots.addActionListener(menuListener);
return popup;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu getPopupMenu() {
if (memoryResPopupMenu == null) {
memoryResPopupMenu = new JPopupMenu();
if (GoToSource.isAvailable()) {
Font boldfont = memoryResPopupMenu.getFont().deriveFont(Font.BOLD);
popupShowSource = new JMenuItem();
popupShowSource.setFont(boldfont);
popupShowSource.setText(GO_SOURCE_POPUP_ITEM_NAME);
memoryResPopupMenu.add(popupShowSource);
popupShowSource.addActionListener(this);
}
if (snapshot.containsStacks()) {
if (GoToSource.isAvailable()) memoryResPopupMenu.addSeparator();
popupShowStacks = new JMenuItem();
popupShowStacks.setText(SHOW_STACK_TRACES_POPUP_ITEM_NAME);
memoryResPopupMenu.add(popupShowStacks);
popupShowStacks.addActionListener(this);
}
}
return memoryResPopupMenu;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu getPopupMenu() {
if (popup == null) {
popup = new JPopupMenu();
if (GoToSource.isAvailable()) {
Font boldfont = popup.getFont().deriveFont(Font.BOLD);
popupShowSource = new JMenuItem();
popupShowSource.setText(GO_SOURCE_POPUP_ITEM);
popupShowSource.setFont(boldfont);
popup.add(popupShowSource);
popupShowSource.addActionListener(this);
}
if (snapshot.containsStacks()) {
if (GoToSource.isAvailable()) popup.addSeparator();
popupShowStacks = new JMenuItem();
popupShowStacks.setText(STACK_TRACES_POPUP_ITEM);
popup.add(popupShowStacks);
popupShowStacks.addActionListener(this);
}
}
return popup;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui
protected JPopupMenu getPopupMenu() {
if (memoryResPopupMenu == null) {
memoryResPopupMenu = new JPopupMenu();
if (GoToSource.isAvailable()) {
Font boldfont = memoryResPopupMenu.getFont().deriveFont(Font.BOLD);
popupShowSource = new JMenuItem();
popupShowSource.setFont(boldfont);
popupShowSource.setText(GO_SOURCE_POPUP_ITEM_NAME);
memoryResPopupMenu.add(popupShowSource);
popupShowSource.addActionListener(this);
}
if (snapshot.containsStacks()) {
if (GoToSource.isAvailable()) memoryResPopupMenu.addSeparator();
popupShowStacks = new JMenuItem();
popupShowStacks.setText(SHOW_STACK_TRACES_POPUP_ITEM_NAME);
memoryResPopupMenu.add(popupShowStacks);
popupShowStacks.addActionListener(this);
}
}
return memoryResPopupMenu;
}
代码示例来源: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: CognizantQAHub/Cognizant-Intelligent-Test-Scripter
/**
* Add list orecentProjFile recent projects as Menu Items to the Recent
* projects menu
*
*
* @param recentProj instance orecentProjFile the menu to address
* <code>Recent Projects</code>
*/
public void updateMenu(JMenu recentProj) {
recentProj.removeAll();
try {
for (String file : recentProjects) {
recentItemMenu = new JMenuItem();
recentItemMenu.setFont(new java.awt.Font("sansserif", 0, 11));
recentItemMenu.setText(toName(file));
recentItemMenu.setToolTipText(file);
recentProj.add(recentItemMenu);
addlistener(recentItemMenu);
}
} catch (Exception ex) {
Logger.getLogger(RecentItems.class.getName()).log(Level.SEVERE, null, ex);
}
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/** Adds an {@code Action} to the popup menu.
* <p>
* The {@code Action} is represented by a {@code JMenuItem}.
*/
public AbstractButton add(Action action) {
JMenuItem item = getPopupMenu().add(action);
if (getColumnCount() > 1) {
item.setUI(new PaletteMenuItemUI());
}
item.setFont(itemFont);
return item;
}
代码示例来源:origin: abc9070410/JComicDownloader
private JMenuItem getMenuItem(String text, String enText, Icon icon) {
text = Common.getStringUsingDefaultLanguage(text, enText); // 使用預設語言
JMenuItem menuItem = new JMenuItem(text, icon);
menuItem.addActionListener(this);
if (SetUp.getUsingBackgroundPicOfMainFrame()) { // 若設定為透明,就用預定字體。
menuItem.setForeground(SetUp.getMainFrameMenuItemDefaultColor());
//menuItem.addMouseListener( this );
//menuItem.setOpaque( true );
}
if (SetUp.getSkinClassName().matches(".*napkin.*")) {
// 因為napkin的預設字型不太清楚,所以用選定字型
menuItem.setFont(SetUp.getDefaultFont(- 3));
}
return menuItem;
}
代码示例来源:origin: atarw/material-ui-swing
@Override
public void installUI (JComponent c) {
super.installUI (c);
JMenuItem menuItem = (JMenuItem) c;
menuItem.setFont (UIManager.getFont ("MenuItem.font"));
menuItem.setBackground (UIManager.getColor ("MenuItem.background"));
menuItem.setForeground (UIManager.getColor ("MenuItem.foreground"));
menuItem.setHorizontalAlignment (SwingConstants.LEFT);
menuItem.setVerticalAlignment (SwingConstants.CENTER);
menuItem.setBorder (UIManager.getBorder ("MenuItem.border"));
}
代码示例来源:origin: org.biojava.thirdparty/forester
static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
if ( !configuration.isUseNativeUI() ) {
label.setBackground( configuration.getGuiMenuBackgroundColor() );
label.setForeground( configuration.getGuiMenuTextColor() );
label.setOpaque( true );
}
label.setSelected( false );
label.setEnabled( false );
return label;
}
代码示例来源: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
JMenuItem customizeJMenuItem( final JMenuItem jmi ) {
if ( jmi != null ) {
jmi.setFont( MainFrame.menu_font );
if ( !getConfiguration().isUseNativeUI() ) {
jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
}
jmi.addActionListener( this );
}
return jmi;
}
代码示例来源:origin: org.biojava.thirdparty/forester
void customizeJMenuItem( final JMenuItem jmi ) {
if ( jmi != null ) {
jmi.setFont( MainFrame.menu_font );
if ( !getConfiguration().isUseNativeUI() ) {
jmi.setBackground( getConfiguration().getGuiMenuBackgroundColor() );
jmi.setForeground( getConfiguration().getGuiMenuTextColor() );
}
jmi.addActionListener( this );
}
}
内容来源于网络,如有侵权,请联系作者删除!