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

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

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

JToolBar.getComponentCount介绍

暂无

代码示例

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

@Override
public Dimension getPreferredSize() {
  Component[] comps = getAllComponents();
  Insets insets = getInsets();
  int width = null == insets ? 0 : insets.left + insets.right;
  int height = null == insets ? 0 : insets.top + insets.bottom;
  for (int i = 0; i < comps.length; i++) {
    Component comp = comps[i];
  if (!comp.isVisible()) {
  continue;
  }
    width += getOrientation() == HORIZONTAL ? comp.getPreferredSize().width : comp.getPreferredSize().height;
    height = Math.max( height, getOrientation() == HORIZONTAL ? comp.getPreferredSize().height : comp.getPreferredSize().width );
  }
  if(overflowToolbar.getComponentCount() > 0) {
    width += getOrientation() == HORIZONTAL ? overflowButton.getPreferredSize().width : overflowButton.getPreferredSize().height;
  }
  Dimension dim = getOrientation() == HORIZONTAL ? new Dimension(width, height) : new Dimension(height, width);
  return dim;        
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

@Override
public int getComponentCount() {
  return toolbar.getComponentCount();
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Disable the tab/button for each visible perspective
 */
public void disableAllPerspectiveTabs() {
 for (int i = 0; i < m_perspectiveToolBar.getComponentCount(); i++) {
  m_perspectiveToolBar.getComponent(i).setEnabled(false);
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Enable the tab/button for each visible perspective
 */
public void enableAllPerspectiveTabs() {
 for (int i = 0; i < m_perspectiveToolBar.getComponentCount(); i++) {
  m_perspectiveToolBar.getComponent(i).setEnabled(true);
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Enable the tab/button for each visible perspective
 */
public void enableAllPerspectiveTabs() {
 for (int i = 0; i < m_perspectiveToolBar.getComponentCount(); i++) {
  m_perspectiveToolBar.getComponent(i).setEnabled(true);
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Disable the tab/button for each visible perspective
 */
public void disableAllPerspectiveTabs() {
 for (int i = 0; i < m_perspectiveToolBar.getComponentCount(); i++) {
  m_perspectiveToolBar.getComponent(i).setEnabled(false);
 }
}

代码示例来源:origin: org.jspresso.framework/jspresso-swing-components

/**
 * Delegates to the internal editor pane.
 * @param b
 *          editable.
 * @see javax.swing.text.JTextComponent#setEditable(boolean)
 */
public void setEditable(boolean b) {
 editorPane.setEditable(b);
 int scCount = toolBar.getComponentCount();
 for (int i = 0; i < scCount; i++) {
  toolBar.getComponentAtIndex(i).setEnabled(b);
 }
 toolBar.setEnabled(b);
}

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

/**
 * The separator will be inserted only if it is really necessary
 */
@Override
public void addSeparator ()
{
  int count = super.getComponentCount();
  if ((count > 0) && !(getComponent(count - 1) instanceof JSeparator)) {
    super.addSeparator(gap);
  }
}

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

/**
 * Remove any potential orphan separator at the end of the tool bar
 *
 * @param toolBar the toolBar to purge
 */
public static void purgeSeparator (JToolBar toolBar)
{
  int count = toolBar.getComponentCount();
  if (toolBar.getComponent(count - 1) instanceof JSeparator) {
    toolBar.remove(count - 1);
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = COUNT_JSDOC)
@Undesignable
@Override
public int getCount() {
  return super.getComponentCount();
}

代码示例来源:origin: net.sf.sfac/sfac-core

public void toolbarCreated(ActionRepository repo, JToolBar toolbar) {
  int insertIndex = toolbar.getComponentCount() - 4;
  toolbar.setBorder(new PartialLineBorder(new Color(153, 153, 153), PartialLineBorder.BOTTOM, 2));
  toolbar.add(new JLabel("Current Profile:"), insertIndex);
  toolbar.add(Box.createHorizontalStrut(4), insertIndex + 1);
  profilesCombo = new JComboBox(profiles);
  Dimension preferred = profilesCombo.getPreferredSize();
  profilesCombo.setMaximumSize(preferred);
  profilesCombo.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        checkActionStates();
        refreshProfile();
      }
    }
  });
  toolbar.add(profilesCombo, insertIndex + 2);
  toolbar.add(Box.createHorizontalGlue());
}

代码示例来源:origin: net.sf.doolin/doolin-gui

/**
 * Copies items of a tool bar to another tool bar
 * 
 * @param targetBar
 *            Target tool bar
 * @param sourceBar
 *            Source tool bar
 */
public static void copyToolbar(JToolBar targetBar, JToolBar sourceBar) {
  // List of source component
  List<Component> sourceComponents = new ArrayList<Component>();
  int count = sourceBar.getComponentCount();
  for (int i = 0; i < count; i++) {
    Component c = sourceBar.getComponent(i);
    sourceComponents.add(c);
  }
  // Clean
  targetBar.removeAll();
  // Copy
  for (Component c : sourceComponents) {
    targetBar.add(c);
  }
}

代码示例来源:origin: mucommander/mucommander

@Override
 public void componentResized(ComponentEvent e) {
  int nbToolbarComponents = toolbar.getComponentCount();
  final boolean aFlag = nbToolbarComponents>0 && !isVisible(toolbar.getComponent(nbToolbarComponents-1), null);
  setVisible(aFlag);
  moreToolbar.setVisible(aFlag);
 }
});

代码示例来源:origin: hneemann/Digital

/**
 * Add an action to the toolbar.
 * The given action is wrapped by an action which counts the usage.
 * So its possible to remove the item which is not used the longest time when the toolbar becomes to large.
 *
 * @param action the action
 */
public void add(InsertAction action) {
  lastInsertAction = action;
  if (!contains(action)) {
    WrapperAction wrapper = new WrapperAction(action, bar.getComponentCount());
    wrappers.add(wrapper);
    bar.add(wrapper).setToolTipText(action.getNode().getToolTipText());
    if (wrappers.size() > MAX_ICONS) {
      int oldest = findOldestIndex();
      removeWrapperFromToolBar(wrappers.get(oldest));
      wrappers.remove(oldest);
    }
  }
}

代码示例来源:origin: akquinet/jbosscc-as7-examples

/**
 * Removes a no longer available <tt>SimpleShape</tt> from the drawing
 * frame.
 *
 * @param name
 *            The name of the <tt>SimpleShape</tt> to remove.
 **/
public void removeShape(String name) {
  m_shapes.remove(name);
  if ((m_selected != null) && m_selected.equals(name)) {
    m_selected = null;
  }
  for (int i = 0; i < m_toolbar.getComponentCount(); i++) {
    JButton sb = (JButton) m_toolbar.getComponent(i);
    if (sb.getActionCommand().equals(name)) {
      m_toolbar.remove(i);
      m_toolbar.invalidate();
      validate();
      repaint();
      break;
    }
  }
  if ((m_selected == null) && (m_toolbar.getComponentCount() > 0)) {
    ((JButton) m_toolbar.getComponent(0)).doClick();
  }
}

代码示例来源:origin: com.fifesoft.rtext/fife.common

public int refreshDockableWindowButtons() {
  while (toolbar.getComponentCount()>0) {
    toolbar.getComponent(0).removeMouseListener(this);
    toolbar.remove(0);
  }
  for (int i=0; i<windowPanel.getDockableWindowCount(); i++) {
    DockableWindow dwind = windowPanel.getDockableWindowAt(i);
    Icon icon = dwind.getIcon();
    JButton b = new JButton(icon);
    b.setToolTipText(dwind.getDockableWindowName());
    b.setOpaque(false);
    b.putClientProperty("DockableWindow", dwind);
    final int index = i;
    b.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        windowPanel.setActiveDockableWindow(index);
        setCollapsed(false);
      }
    });
    b.addMouseListener(this);
    toolbar.add(b);
  }
  WebLookAndFeelUtils.fixToolbar(toolbar, true);
  toolbar.revalidate();
  return toolbar.getComponentCount();
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

public static void configuraWeblaf(JToolBar barraDeFerramentas) {
  if (!WeblafUtils.weblafEstaInstalado()) {
    return;
  }
  ((WebToolBarUI) barraDeFerramentas.getUI()).setUndecorated(true);
  for (int i = 0; i < barraDeFerramentas.getComponentCount(); i++) {
    Component componente = barraDeFerramentas.getComponent(i);
    if (componente instanceof AbstractButton) {
      AbstractButton botao = (AbstractButton) barraDeFerramentas.getComponent(i);
      ((WebButtonUI) botao.getUI()).setRolloverDecoratedOnly(true);
    }
  }
}

代码示例来源:origin: ro.isdc.wro4j/rhino

/**
 * Enables or disables the menu and tool bars with respect to the
 * state of script execution.
 */
private void updateEnabled(boolean interrupted) {
  ((Menubar)getJMenuBar()).updateEnabled(interrupted);
  for (int ci = 0, cc = toolBar.getComponentCount(); ci < cc; ci++) {
    boolean enableButton;
    if (ci == 0) {
      // Break
      enableButton = !interrupted;
    } else {
      enableButton = interrupted;
    }
    toolBar.getComponent(ci).setEnabled(enableButton);
  }
  if (interrupted) {
    toolBar.setEnabled(true);
    // raise the debugger window
    int state = getExtendedState();
    if (state == Frame.ICONIFIED) {
      setExtendedState(Frame.NORMAL);
    }
    toFront();
    context.setEnabled(true);
  } else {
    if (currentWindow != null) currentWindow.setPosition(-1);
    context.setEnabled(false);
  }
}

代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger

/**
 * Enables or disables the menu and tool bars with respect to the
 * state of script execution.
 */
private void updateEnabled(boolean interrupted) {
  ((Menubar)getJMenuBar()).updateEnabled(interrupted);
  for (int ci = 0, cc = toolBar.getComponentCount(); ci < cc; ci++) {
    boolean enableButton;
    if (ci == 0) {
      // Break
      enableButton = !interrupted;
    } else {
      enableButton = interrupted;
    }
    toolBar.getComponent(ci).setEnabled(enableButton);
  }
  if (interrupted) {
    toolBar.setEnabled(true);
    // raise the debugger window
    int state = getExtendedState();
    if (state == Frame.ICONIFIED) {
      setExtendedState(Frame.NORMAL);
    }
    toFront();
    context.enable();
  } else {
    if (currentWindow != null) currentWindow.setPosition(-1);
    context.disable();
  }
}

代码示例来源:origin: org.icepdf.os/icepdf-viewer

public JToolBar buildUtilityToolBar(boolean embeddableComponent, PropertiesManager propertiesManager) {
  JToolBar toolbar = new JToolBar();
  commonToolBarSetup(toolbar, false);
  // if embeddable component, we don't want to create the open dialog, as we
  // have no window manager for this case.
  if ((!embeddableComponent) &&
      (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_OPEN)))
    addToToolBar(toolbar, buildOpenFileButton());
  if (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_SAVE))
    addToToolBar(toolbar, buildSaveAsFileButton());
  if (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_PRINT))
    addToToolBar(toolbar, buildPrintButton());
  if (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_SEARCH))
    addToToolBar(toolbar, buildSearchButton());
  if (PropertiesManager.checkAndStoreBooleanProperty(propertiesManager, PropertiesManager.PROPERTY_SHOW_UTILITY_UPANE))
    addToToolBar(toolbar, buildShowHideUtilityPaneButton());
  // Don't bother with this toolbar if we don't have any visible buttons
  if (toolbar.getComponentCount() == 0) {
    return null;
  }
  return toolbar;
}

相关文章

JToolBar类方法