javax.swing.JMenuItem.setUI()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中javax.swing.JMenuItem.setUI()方法的一些代码示例,展示了JMenuItem.setUI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.setUI()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:setUI

JMenuItem.setUI介绍

暂无

代码示例

代码示例来源:origin: ron190/jsql-injection

menuItem.setUI(
    new BasicRadioButtonMenuItemUI() {
      @Override
menuItemDump.setUI(
  new BasicCheckBoxMenuItemUI() {
    @Override

代码示例来源:origin: stackoverflow.com

setUI((MenuItemUI) UIManager.getUI(this));

代码示例来源:origin: ron190/jsql-injection

comboMenuVendor.setText(vendor.toString());
});
itemRadioVendor.setUI(
  new BasicRadioButtonMenuItemUI() {
    @Override

代码示例来源:origin: stackoverflow.com

final JMenuItem[] items = new JMenuItem[10];
 for (int i = 0; i < 10; i++) {
   JMenuItem item = new JMenuItem("Item #"+String.valueOf(i));
   itemPanel.add(item);
   item.setUI(new MyUI());
   items[i] = item;
 }
 menu.updateUI(); <<<<<<--------
 menu.add(itemPanel);

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    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));
    }
    // this is the largest size of an image used in a JMenuItem, before the size of the JMenuItem is forced to be larger
    int height = SwingUtil.getLargestIconHeightForButton(jMenuItem);
    iconSize.set(height);
  }
});

代码示例来源: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.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: com.fifesoft.rtext/fife.common

private void addSwatch(Color color, GridBagLayout gridbag,
          GridBagConstraints c) {
  // We want a menu item that uses a custom UI even when the
  // user changes it.
  JMenuItem item = new JMenuItem(new ColorIcon(color, 16,16));
  item.setToolTipText(createToolTipText(color));
  item.setUI(new SwatchMenuItemUI());
  item.addActionListener(popupListener);
  gridbag.setConstraints(item, c);
  add(item);
}

代码示例来源:origin: com.dorkbox/SystemTray

SwingMenuItem(final SwingMenu parent, Entry entry) {
  this.parent = parent;
  if (SystemTray.SWING_UI != null) {
    _native.setUI(SystemTray.SWING_UI.getItemUI(_native, entry));
  }
  _native.setHorizontalAlignment(SwingConstants.LEFT);
  parent._native.add(_native);
  if (transparentIcon == 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));
      }
      // 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();
      transparentIcon = new ImageIcon(ImageResizeUtil.getTransparentImage(menuImageSize)
                              .getAbsolutePath());
    } catch (Exception e) {
      SystemTray.logger.error("Error creating transparent image.", e);
    }
  }
  _native.setIcon(transparentIcon);
}

代码示例来源: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);
    }
  }
}

相关文章

JMenuItem类方法