javax.swing.JMenuBar.validate()方法的使用及代码示例

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

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

JMenuBar.validate介绍

暂无

代码示例

代码示例来源:origin: org.biojava.thirdparty/forester

private void doUpdateProcessMenu() {
  if ( _process_pool.size() > 0 ) {
    if ( _process_menu == null ) {
      _process_menu = createMenu( "", getConfiguration() );
      _process_menu.setForeground( Color.RED );
    }
    _process_menu.removeAll();
    final String text = "processes running: " + _process_pool.size();
    _process_menu.setText( text );
    _jmenubar.add( _process_menu );
    for( int i = 0; i < _process_pool.size(); ++i ) {
      final ProcessRunning p = _process_pool.getProcessByIndex( i );
      _process_menu.add( customizeJMenuItem( new JMenuItem( p.getName() + " [" + p.getStart() + "]" ) ) );
    }
  }
  else {
    if ( _process_menu != null ) {
      _process_menu.removeAll();
      _jmenubar.remove( _process_menu );
    }
  }
  _jmenubar.validate();
  _jmenubar.repaint();
  repaint();
}

代码示例来源:origin: igniterealtime/Spark

/**
 * Rescaning our bookmarks and remaking menu items
 *
 * @param bookmarkMenu menu Jmenu
 */
public void rescan(JMenu bookmarkMenu) {
  bookmarkMenu.removeAll(); // removing old menus
  try {
    setBookmarks(bookmarkMenu); // making new 
    int onPanel = SparkManager.getMainWindow().getMenu().getComponentIndex(bookmarkMenu);
    if (onPanel < 0) {
      if (bookmarkMenu.getMenuComponentCount() > 0) {
        int menuCount = SparkManager.getMainWindow().getMenu().getMenuCount();
        SparkManager.getMainWindow().getMenu().add(bookmarkMenu, menuCount - 2);
      }
    }
    if (onPanel >= 0) {
      if (bookmarkMenu.getMenuComponentCount() <= 0) {
        SparkManager.getMainWindow().getMenu().remove(bookmarkMenu);
      }
    }
    SparkManager.getMainWindow().getMenu().invalidate();
    SparkManager.getMainWindow().getMenu().validate();
    SparkManager.getMainWindow().getMenu().repaint();
  } catch (XMPPException | SmackException | InterruptedException ex) {
    Log.error(ex);
  }
}

相关文章