javax.swing.JDesktopPane.getComponentCount()方法的使用及代码示例

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

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

JDesktopPane.getComponentCount介绍

暂无

代码示例

代码示例来源:origin: chewiebug/GCViewer

private void closeAllButSelectedDocument(GCViewerGui gui) {
  if (gui.getSelectedGCDocument() != null) {
    GCDocument selected = gui.getSelectedGCDocument();
    for (int i = gui.getDesktopPane().getComponentCount()-1; i > 0; --i) {
      if (gui.getDesktopPane().getComponent(i) != selected) {
        ((JInternalFrame)gui.getDesktopPane().getComponent(i)).dispose();
      }
    }
    gui.getSelectedGCDocument().doDefaultCloseAction();
  }
}

代码示例来源:origin: chewiebug/GCViewer

@Override
public void internalFrameClosing(InternalFrameEvent e) {
  JInternalFrame internalFrame = e.getInternalFrame();
  internalFrame.removeInternalFrameListener(this);
  internalFrame.getRootPane().remove(internalFrame);
  if (internalFrame.getRootPane().getComponentCount() == 0) {
    getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(false);
  }
  
  // remove menuitem from menu and from button group
  JMenu windowMenu = getMenuBar(e).getWindowMenu();
  for (int i = 2; i < windowMenu.getItemCount(); i++) {
    JMenuItem item = windowMenu.getItem(i);
    if (((WindowMenuItemAction) item.getAction()).getInternalFrame() == internalFrame) {
      getMenuBar(e).removeFromWindowMenuGroup(item);
      break;
    }
  }
  // if this internalFrame is the last to be open, update the menu state
  // -> otherwise any settings done by the user are lost
  if (getGCViewerGui(e).getDesktopPane().getComponentCount() == 1) {
    updateMenuItemState(e);
    // set same menustate, when the last is closed as is set for deactivated
    internalFrameDeactivated(e);
  }
  // if some thread is still loading, it should stop now
  getSelectedGCDocument(e).getGCResources().stream().forEach(gcResource -> gcResource.setIsReadCancelled(true));
}

代码示例来源:origin: com.numdata/numdata-swing

/**
 * Returns the number of visible windows.
 *
 * @return Number of visible windows.
 */
public int getVisibleWindowCount()
{
  int result = 0;
  for ( int i = 0, componentCount = _desktop.getComponentCount(); i < componentCount; i++ )
  {
    final Component component = _desktop.getComponent( i );
    if ( component instanceof JInternalFrame )
    {
      final JInternalFrame frame = (JInternalFrame)component;
      if ( frame.isVisible() )
      {
        result++;
      }
    }
  }
  return result;
}

代码示例来源:origin: senbox-org/snap-desktop

private TopComponent closeInternalFrame(JInternalFrame internalFrame, boolean removeTab) {
  internalFrame.removeInternalFrameListener(internalFrameListener);
  TopComponent topComponent = getTopComponent(internalFrame);
  topComponent.removePropertyChangeListener(propertyChangeListener);
  Object internalFrameID = getInternalFrameID(topComponent);
  idToBoundsMap.put(internalFrameID, new Rectangle(internalFrame.getBounds()));
  TabData tab = frameToTabMap.get(internalFrame);
  if (tab != null) {
    if (removeTab) {
      int tabIndex = tabbedContainer.getModel().indexOf(tab);
      if (tabIndex >= 0) {
        tabbedContainer.getModel().removeTab(tabIndex);
      }
    }
    tabToFrameMap.remove(tab);
  }
  frameToTabMap.remove(internalFrame);
  internalFrame.dispose();
  desktopPane.remove(internalFrame);
  if (desktopPane.getComponentCount() == 0) {
    tabbedContainer.setVisible(false);
  }
  // make sure the topComponent's parent is not the internalFrame which we just closed
  internalFrame.setContentPane(new TopComponent());
  return topComponent;
}

相关文章