javax.swing.JToolBar#getComponents ( )源码实例Demo

下面列出了javax.swing.JToolBar#getComponents ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: AbstractToolbarFactory.java
public void update (String containerCtx) {
//        System.err.println("ToolbarFactory update " + containerCtx);
        JToolBar tb = (JToolBar) mappings.get(munge(containerCtx));
        synchronized (tb.getTreeLock()) {
    //        System.err.println("Toolbar to update: " + tb);
            ActionProvider provider = getEngine().getActionProvider();
            if (tb != null) {
                Component[] c = tb.getComponents();
                for (int i=0; i < c.length; i++) {
                    if (c[i] instanceof AbstractButton) {
                        AbstractButton b = (AbstractButton) c[i];
                        String action = (String) b.getClientProperty (KEY_ACTION);
                        configureToolbarButton (b, containerCtx, action, provider,
                            getEngine().getContextProvider().getContext());
                    }
                }

            } else {
                System.err.println("Asked to update non existent toolbar " + containerCtx);
            }
        }
    }
 
源代码2 项目: openAGV   文件: OpenTCSView.java
private void configureToolBarButtons(JToolBar bar) {
  final Dimension dimButton = new Dimension(32, 34);
  for (Component comp : bar.getComponents()) {
    if (comp instanceof JButton || comp instanceof JToggleButton) {
      JComponent tbButton = (JComponent) comp;
      tbButton.setMaximumSize(dimButton);
      tbButton.setPreferredSize(dimButton);
      tbButton.setBorder(new EtchedBorder());
    }
  }
}
 
源代码3 项目: openAGV   文件: PaletteToolBarBorder.java
@Override
public void paintBorder(Component component, Graphics gr, int x, int y, int w, int h) {
  Graphics2D g = (Graphics2D) gr;

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
  g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

  if ((component instanceof JToolBar) /* && ((((JToolBar) component).getUI()) instanceof PaletteToolBarUI) */) {
    JToolBar c = (JToolBar) component;

    if (c.isFloatable()) {
      int borderColor = 0x80ff0000;
      float[] stops = ENABLED_STOPS;
      Color[] stopColors = ENABLED_STOP_COLORS;

      g.setColor(new Color(borderColor, true));
      LinearGradientPaint lgp = new LinearGradientPaint(
          new Point2D.Float(1, 1), new Point2D.Float(19, 1),
          stops, stopColors,
          MultipleGradientPaint.CycleMethod.REPEAT);
      g.setPaint(lgp);
      g.fillRect(1, 1, 7 - 2, h - 2);
      ImageIcon icon = new ImageIcon(getClass().getResource("/org/opentcs/guing/res/symbols/toolbar/border.jpg"));

      if (c.getComponentCount() != 0 && !(c.getComponents()[0] instanceof JLabel)) {
        JLabel label = new JLabel(icon);
        label.setFocusable(false);
        c.add(label, 0);
        label.getParent().setBackground(label.getBackground());
        label.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
      }
    }
  }
}
 
源代码4 项目: netbeans   文件: PageInspectorImpl.java
/**
 * Uninitializes the selection mode (removes the page inspection
 * component/s from the toolbar).
 * 
 * @param toolBar toolBar to remove the buttons from.
 */
void uninitSelectionMode(JToolBar toolBar) {
    if (toolBar != null) {
        for (Component component : toolBar.getComponents()) {
            if (SELECTION_MODE_COMPONENT_NAME.equals(component.getName())) {
                toolBar.remove(component);
                break;
            }
        }
    }
}
 
源代码5 项目: gate-core   文件: DocumentEditor.java
/**
 * Updates the selected state of the buttons on one of the toolbars.
 * 
 * @param toolbar
 *          toolbar to update
 */
protected void updateBar(JToolBar toolbar) {
  Component btns[] = toolbar.getComponents();
  if(btns != null) {
    for(Component btn : btns) {
      if(btn instanceof ViewButton) ((ViewButton)btn).updateSelected();
    }
  }
}
 
源代码6 项目: Cognizant-Intelligent-Test-Scripter   文件: UI2.java
/**
 * enable / disable components
 *
 * @param t
 * @param s
 */
private void eComponents(JToolBar t, boolean s) {
    for (Component c : t.getComponents()) {
        c.setEnabled(s);
    }
}
 
源代码7 项目: WorldPainter   文件: AKDockLayout.java
private void flipSeparators(Component c, int orientn) {

        if (c != null && c instanceof JToolBar
                && UIManager.getLookAndFeel().getName().toLowerCase().indexOf("windows")
                != -1) {

            JToolBar jtb = (JToolBar) c;

            Component comps[] = jtb.getComponents();

            if (comps != null && comps.length > 0) {

                for (int i = 0; i < comps.length; i++) {

                    try {

                        Component component = comps[i];

                        if (component != null) {

                            if (component instanceof JSeparator) {

                                jtb.remove(component);

                                JSeparator separ = new JSeparator();

                                if (orientn == SwingConstants.VERTICAL) {

                                    separ.setOrientation(SwingConstants.VERTICAL);

                                    separ.setMinimumSize(new Dimension(2, 6));

                                    separ.setPreferredSize(new Dimension(2, 6));

                                    separ.setMaximumSize(new Dimension(2, 100));

                                } else {

                                    separ.setOrientation(SwingConstants.HORIZONTAL);

                                    separ.setMinimumSize(new Dimension(6, 2));

                                    separ.setPreferredSize(new Dimension(6, 2));

                                    separ.setMaximumSize(new Dimension(100, 2));

                                }

                                jtb.add(separ, i);

                            }

                        }

                    } catch (Exception e) {

                        e.printStackTrace();

                    }

                }

            }

        }

    }