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

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

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

JMenuItem.setHorizontalAlignment介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

/** Method to prepare the margins and text positions.
*/
static void prepareMargins(JMenuItem item, Action action) {
  item.setHorizontalTextPosition(JMenuItem.RIGHT);
  item.setHorizontalAlignment(JMenuItem.LEFT);
}

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

JMenuItem item1 = new JMenuItem("Item 1");
 JMenuItem item2 = new JMenuItem("Item ________ 2");
 JMenuItem item3 = new JMenuItem("Item 3");
 item1.setHorizontalAlignment(SwingConstants.RIGHT);
 item3.setHorizontalAlignment(SwingConstants.CENTER);

代码示例来源:origin: Audiveris/audiveris

/**
 * Insert a pseudo-item, to be used as a menu title.
 *
 * @param menu the containing menu
 * @param text the title text
 */
public static void insertTitle (JMenu menu,
                String text)
{
  JMenuItem title = new JMenuItem(text);
  title.setHorizontalAlignment(SwingConstants.CENTER);
  title.setEnabled(false);
  menu.add(title);
  menu.addSeparator();
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Method to prepare the margins and text positions.
*/
static void prepareMargins (JMenuItem item, Action action) {
  item.setHorizontalTextPosition(JMenuItem.RIGHT);
  item.setHorizontalAlignment(JMenuItem.LEFT);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Method to prepare the margins and text positions.
*/
static void prepareMargins (JMenuItem item, Action action) {
  item.setHorizontalTextPosition(JMenuItem.RIGHT);
  item.setHorizontalAlignment(JMenuItem.LEFT);
}

代码示例来源:origin: GoldenGnu/jeveassets

private static void createMenuItem(final JPopupMenu jPopupMenu, final String text, final String toolTipText, final Icon icon) {
  JMenuItem jMenuItem = new JMenuItem(text);
  jMenuItem.setToolTipText(toolTipText);
  jMenuItem.setEnabled(false);
  jMenuItem.setDisabledIcon(icon);
  jMenuItem.setForeground(Color.BLACK);
  jMenuItem.setHorizontalAlignment(SwingConstants.RIGHT);
  jPopupMenu.add(jMenuItem);
}

代码示例来源: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: Audiveris/audiveris

/**
   * Triggered when mouse is pressed.
   *
   * @param e mouse event
   */
  @Override
  public void mousePressed (MouseEvent e)
  {
    if (isContextWanted(e)) {
      JPopupMenu popup = new SeparablePopupMenu();
      // A title for this menu
      JMenuItem head = new JMenuItem("Boards for selection:");
      head.setHorizontalAlignment(SwingConstants.CENTER);
      head.setEnabled(false);
      popup.add(head);
      popup.addSeparator();
      for (Board board : boards) {
        JMenuItem item = new JCheckBoxMenuItem(board.getName(), board.isSelected());
        item.addItemListener(this);
        item.setToolTipText(
            board.isSelected() ? "Deselect this board?" : "Select this board?");
        popup.add(item);
      }
      popup.show(component, e.getX(), e.getY());
    }
  }
}

代码示例来源: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: Audiveris/audiveris

title.setHorizontalAlignment(SwingConstants.CENTER);
title.setEnabled(false);
popup.add(title);

代码示例来源: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: GoldenGnu/jeveassets

jIskValue.setEnabled(false);
jIskValue.setForeground(Color.BLACK);
jIskValue.setHorizontalAlignment(SwingConstants.RIGHT);
jIskValue.setDisabledIcon(Images.TOOL_VALUES.getIcon());
jPopupMenu.add(jIskValue);
jDateValue.setEnabled(false);
jDateValue.setForeground(Color.BLACK);
jDateValue.setHorizontalAlignment(SwingConstants.RIGHT);
jDateValue.setDisabledIcon(Images.EDIT_DATE.getIcon());
jPopupMenu.add(jDateValue);

代码示例来源:origin: GoldenGnu/jeveassets

jRemove.setHorizontalAlignment(JButton.LEFT);
jRemove.setActionCommand(StockpileDialogAction.REMOVE.name());
jRemove.addActionListener(listener);
jClone.setHorizontalAlignment(JButton.LEFT);
jClone.setActionCommand(StockpileDialogAction.CLONE.name());
jClone.addActionListener(listener);

相关文章

JMenuItem类方法