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

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

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

JMenuItem.setBorder介绍

暂无

代码示例

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

private JMenuItem createColoredSeparator(Color color){
   JMenuItem separator = new JMenuItem();
   separator.setPreferredSize(new Dimension(50,50)); //Increased to highlight whats happening
   //Imitate the default raised border
   Border raisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED,
       UIManager.getColor("MenuItem.background"),UIManager.getColor("MenuItem.background").darker());
   //Merge the borders with the raised border applied outside of the border concealing part of the background
   separator.setBorder(new CompoundBorder(
       raisedBorder, BorderFactory.createLineBorder(UIManager.getColor("MenuItem.background"), 8)));
   separator.setBackground(color);
   separator.setEnabled(false); //make the item un-clickable so menu doesn't close
   return separator;
 }

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

private static void createMenuItemGroup(final JPopupMenu jPopupMenu, final String text, final Icon icon) {
  JMenuItem jMenuItem = new JMenuItem(text);
  if (icon != null) {
    jMenuItem.setDisabledIcon(icon);
  }
  jMenuItem.setEnabled(false);
  if (border == null) {
    border = BorderFactory.createCompoundBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, jMenuItem.getBackground().darker()),
             BorderFactory.createMatteBorder(1, 0, 0, 0, jMenuItem.getBackground().brighter())),
         BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, jMenuItem.getBackground().brighter()),
             BorderFactory.createMatteBorder(0, 0, 1, 0, jMenuItem.getBackground().darker())));
  }
  jMenuItem.setForeground(Color.BLACK);
  jMenuItem.setBorder(border);
  jMenuItem.setBorderPainted(true);
  jPopupMenu.add(jMenuItem);
}

代码示例来源:origin: sebbrudzinski/Open-LaTeX-Studio

@Override
public void actionPerformed(ActionEvent e) {                
  EditorTopComponent etc = new TopComponentFactory<EditorTopComponent>()
    .getTopComponent(EditorTopComponent.class.getSimpleName());                
  
  etc.getEditorState().setSpellCheckActive(!etc.getEditorState().isSpellCheckActive());
  etc.getEditorState().setDirty(true);
  if(etc.getEditorState().isSpellCheckActive()) {
    if(specllCheckButton != null) {
      specllCheckButton.setBorder(BorderFactory.createLoweredBevelBorder());
    }
    if(specllCheckMenuItem != null) {
      specllCheckMenuItem.setBorder(BorderFactory.createLoweredBevelBorder());
      specllCheckMenuItem.setBorderPainted(true); //Border will not change without paint
    }            
  } else {
    if(specllCheckButton != null) {
      specllCheckButton.setBorder(BorderFactory.createEmptyBorder());
    }
    if(specllCheckMenuItem != null) {
      specllCheckMenuItem.setBorder(BorderFactory.createEmptyBorder());
      specllCheckMenuItem.setBorderPainted(true); //Border will not change without paint
    }            
  }
}

代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce

private static void alignCheck( JMenuItem item, Dimension size, Border border) {
  Icon icon = item.getIcon();
  
  if ( border != null) {
    item.setBorder( border);
  }
  if ( icon != null && icon.getIconWidth() < size.width) {
    item.setIconTextGap( item.getIconTextGap() + ((size.width - icon.getIconWidth())/2));
  } else if ( icon == null) {
    item.setIcon( new DummyIcon( size));
  }
}

代码示例来源: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.icepdf.os/icepdf-viewer

jmi.setRolloverIcon(new ImageIcon(Images.get("menu_spacer.gif")));
jmi.setBorder(BorderFactory.createEmptyBorder());
jmi.setContentAreaFilled(false);
jmi.setFocusPainted(true);

代码示例来源:origin: datacleaner/DataCleaner

WidgetFactory.createMenuItem("Save as result file", IconUtils.ACTION_SAVE_DARK);
saveAsFileItem.addActionListener(new SaveAnalysisResultActionListener(resultRef, _userPreferences));
saveAsFileItem.setBorder(buttonBorder);
_saveResultsPopupButton.getMenu().add(saveAsFileItem);
exportToHtmlItem
    .addActionListener(new ExportResultToHtmlActionListener(resultRef, _configuration, _userPreferences));
exportToHtmlItem.setBorder(buttonBorder);
_saveResultsPopupButton.getMenu().add(exportToHtmlItem);
    if (component instanceof JMenuItem) {
      final JMenuItem menuItem = (JMenuItem) component;
      menuItem.setBorder(buttonBorder);
      _saveResultsPopupButton.getMenu().add(menuItem);
    } else if (component instanceof AbstractButton) {
        menuItem.addActionListener(listener);
      menuItem.setBorder(buttonBorder);
      _saveResultsPopupButton.getMenu().add(menuItem);

代码示例来源:origin: Exslims/MercuryTrade

moveOut.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, AppThemeColor.ADR_DEFAULT_BORDER));
  moveOut.addActionListener(action -> {
    MercuryStoreUI.adrRemoveComponentSubject.onNext(treeNode.getData());
  if (neighbor.getData() instanceof AdrTrackerGroupDescriptor) {
    JMenuItem moveTo = this.componentsFactory.getMenuItem("Move to " + neighbor.getData().getTitle());
    moveTo.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, AppThemeColor.ADR_DEFAULT_BORDER));
    moveTo.addActionListener(action -> {
      MercuryStoreUI.adrRemoveComponentSubject.onNext(treeNode.getData());
export.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, AppThemeColor.ADR_DEFAULT_BORDER));
export.addActionListener(action -> {
  MercuryStoreUI.adrExportSubject.onNext(treeNode.getData());

相关文章

JMenuItem类方法