javax.swing.JComponent#getComponentCount ( )源码实例Demo

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

源代码1 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getMinimumSize(javax.swing.JComponent)
 */
public Dimension getMinimumSize(JComponent c) {
    if (c.getComponentCount() > 0 && c.getLayout() != null) {
        return null;
    }

    AbstractButton   b      = (AbstractButton) c;
    SeaGlassContext  ss     = getContext(c);
    final SynthStyle style2 = ss.getStyle();
    Dimension        size   = style2.getGraphicsUtils(ss).getMinimumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
                                                                         b.getHorizontalAlignment(), b.getVerticalAlignment(),
                                                                         b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
                                                                         b.getIconTextGap(), b.getDisplayedMnemonicIndex());

    ss.dispose();
    return size;
}
 
源代码2 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getPreferredSize(javax.swing.JComponent)
 */
public Dimension getPreferredSize(JComponent c) {
    if (c.getComponentCount() > 0 && c.getLayout() != null) {
        return null;
    }

    AbstractButton     b             = (AbstractButton) c;
    SeaGlassContext    ss            = getContext(c);
    SynthStyle         style2        = ss.getStyle();
    SynthGraphicsUtils graphicsUtils = style2.getGraphicsUtils(ss);
    Dimension          size          = graphicsUtils.getPreferredSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
                                                                      b.getHorizontalAlignment(),
                                                                      b.getVerticalAlignment(), b.getHorizontalTextPosition(),
                                                                      b.getVerticalTextPosition(), b.getIconTextGap(),
                                                                      b.getDisplayedMnemonicIndex());

    ss.dispose();
    // Make height odd.
    size.height &= ~1;
    return size;
}
 
源代码3 项目: seaglass   文件: SeaGlassButtonUI.java
/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getMaximumSize(javax.swing.JComponent)
 */
public Dimension getMaximumSize(JComponent c) {
    if (c.getComponentCount() > 0 && c.getLayout() != null) {
        return null;
    }

    AbstractButton   b      = (AbstractButton) c;
    SeaGlassContext  ss     = getContext(c);
    final SynthStyle style2 = ss.getStyle();
    Dimension        size   = style2.getGraphicsUtils(ss).getMaximumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
                                                                         b.getHorizontalAlignment(), b.getVerticalAlignment(),
                                                                         b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
                                                                         b.getIconTextGap(), b.getDisplayedMnemonicIndex());

    ss.dispose();
    return size;
}
 
源代码4 项目: LoboBrowser   文件: SwingTasks.java
private static void setEnabledRecursive(final JComponent component, final boolean enabled) {
  component.setEnabled(enabled);
  final int count = component.getComponentCount();
  for (int i = 0; i < count; i++) {
    final Component child = component.getComponent(i);
    if (child instanceof JComponent) {
      final JComponent jchild = (JComponent) child;
      if (enabled) {
        final Boolean nestedEnabling = (Boolean) jchild.getClientProperty(NESTED_ENABLING);
        if ((nestedEnabling == null) || nestedEnabling.booleanValue()) {
          setEnabledRecursive(jchild, true);
        }
      } else {
        setEnabledRecursive(jchild, false);
      }
    }
  }
}
 
源代码5 项目: xdm   文件: BatchPatternDialog.java
private void transparentSpinner(JSpinner spTo2) {
	JComponent c = spTo2.getEditor();
	for (int i = 0; i < c.getComponentCount(); i++) {
		Component ct = c.getComponent(i);
		if (ct instanceof JTextField) {
			ct.setForeground(Color.WHITE);
			ct.setBackground(ColorResource.getDarkBtnColor());
		}
	}
	spTo2.setForeground(Color.WHITE);
	spTo2.setBackground(ColorResource.getDarkBgColor());
	spTo2.setBorder(null);

}
 
源代码6 项目: netbeans   文件: DropTargetLayer.java
private  void drawOpenSpotAtEndOfMenuBar(Graphics2D g2, JComponent mb) {
    Point mblocation = SwingUtilities.convertPoint(mb, new Point(0,0), this);
    if(mb.getComponentCount() > 0) {
        Component lastComp = mb.getComponent(mb.getComponentCount()-1);
        mblocation.x += lastComp.getX() + lastComp.getWidth();
    }
    g2.drawRect(mblocation.x+2, mblocation.y+2, mb.getHeight()-4, mb.getHeight()-4);
}
 
源代码7 项目: ramus   文件: QualifierPreferencesPanel.java
private void clearPopupMenu(JComponent component) {
    component.setComponentPopupMenu(null);
    for (int i = 0; i < component.getComponentCount(); i++) {
        Component c = component.getComponent(i);
        if (c instanceof JComponent)
            clearPopupMenu((JComponent) c);
    }
}
 
源代码8 项目: ramus   文件: ModelPropertiesDialog.java
private void clearPopupMenu(JComponent component) {
    component.setComponentPopupMenu(null);
    for (int i = 0; i < component.getComponentCount(); i++) {
        Component c = component.getComponent(i);
        if (c instanceof JComponent)
            clearPopupMenu((JComponent) c);
    }
}
 
源代码9 项目: magarena   文件: MScreenHelper.java
static void refreshComponentStyle(final JComponent container) {
    for (Component component : container.getComponents()) {
        if (component instanceof JComponent) {
            final JComponent widget = (JComponent)component;
            if (widget.getComponentCount() > 0) {
                refreshComponentStyle(widget);
            }
            if (widget instanceof IThemeStyle) {
                ((IThemeStyle)widget).refreshStyle();
            }
        }
    }
}
 
源代码10 项目: gcs   文件: SkillDefaultEditor.java
private void removeDefault() {
    JComponent parent = (JComponent) getParent();
    parent.remove(this);
    if (parent.getComponentCount() == 0) {
        parent.add(new SkillDefaultEditor());
    }
    parent.revalidate();
    parent.repaint();
    notifyActionListeners();
}
 
源代码11 项目: scelight   文件: LSettingsGui.java
/**
 * Removes previously bounded {@link ISettingChangeListener}s from the specified component, and also from all of its child components recursively.
 * 
 * <p>
 * Implementation simply clears the client property to which the bounded setting change listener was stored for to trigger the previously registered
 * property change listener to take care of the rest.
 * </p>
 * 
 * @param container container of components whose bounded setting change listener to remove
 * 
 * @see #addBindExecuteScl(ISettingChangeListener, ISettingsBean, Set, JComponent)
 */
public static void removeAllBoundedScl( final JComponent container ) {
	// Just for the short name...
	final JComponent c = container;
	
	if ( c.getClientProperty( PROP_BOUNDED_SCL_LIST ) != null )
		c.putClientProperty( PROP_BOUNDED_SCL_LIST, null );
	
	for ( int i = c.getComponentCount() - 1; i >= 0; i-- ) {
		final Component comp = c.getComponent( i );
		if ( comp instanceof JComponent )
			removeAllBoundedScl( (JComponent) comp );
	}
}
 
源代码12 项目: pumpernickel   文件: AnimatedLayout.java
private void registerChildren(JComponent c) {
	String key = "animatedLayout.propertyListener";
	for (int a = 0; a < c.getComponentCount(); a++) {
		JComponent child = (JComponent) c.getComponent(a);
		if (child.getClientProperty(key) == null) {
			child.putClientProperty(key, destinationListener);
			child.addPropertyChangeListener(PROPERTY_DESTINATION,
					destinationListener);
		}
	}
}
 
源代码13 项目: pumpernickel   文件: PumpernickelShowcaseApp.java
private List<String> getKeywords(JComponent jc) {
	List<String> returnValue = new ArrayList<>();
	if (jc instanceof LazyDemoPanel) {
		LazyDemoPanel ldp = (LazyDemoPanel) jc;
		ShowcaseDemo d = ldp.getShowcaseDemo();
		if (d.getKeywords() == null)
			throw new NullPointerException(ldp.demoClassName);
		for (String keyword : d.getKeywords()) {
			returnValue.add(keyword.toLowerCase());
		}
		Class[] classes = d.getClasses();
		if (classes == null)
			throw new NullPointerException(
					d.getClass().getSimpleName());
		for (Class z : classes) {
			int layer = 0;
			/*
			 * Include at least 4 layers: CircularProgressBarUI ->
			 * BasicProgressBarUI -> ProgressBarUI -> ComponentUI
			 */
			while (z != null && !z.equals(Object.class) && layer < 4) {
				returnValue.add(z.getSimpleName().toLowerCase());
				returnValue.add(z.getName().toLowerCase());
				z = z.getSuperclass();
				layer++;
			}
		}
	}
	for (int a = 0; a < jc.getComponentCount(); a++) {
		if (jc.getComponent(a) instanceof JComponent)
			returnValue.addAll(
					getKeywords((JComponent) jc.getComponent(a)));
	}
	return returnValue;
}
 
源代码14 项目: pumpernickel   文件: FileCheckList.java
private static void getCheckBoxes(JComponent jc, List<JCheckBox> list) {
	if (jc instanceof JCheckBox) {
		list.add((JCheckBox) jc);
	}
	for (int a = 0; a < jc.getComponentCount(); a++) {
		if (jc.getComponent(a) instanceof JComponent) {
			getCheckBoxes((JComponent) jc.getComponent(a), list);
		}
	}
}
 
源代码15 项目: snap-desktop   文件: AbstractModalDialog.java
protected void setEnabledComponentsWhileLoading(boolean enabled) {
    JDialog dialog = getJDialog();
    JPanel dialogContentPanel = (JPanel)dialog.getContentPane();

    Stack<JComponent> stack = new Stack<JComponent>();
    stack.push(dialogContentPanel);
    while (!stack.isEmpty()) {
        JComponent component = stack.pop();
        component.setEnabled(enabled);
        int childrenCount = component.getComponentCount();
        for (int i=0; i<childrenCount; i++) {
            Component child = component.getComponent(i);
            if (child instanceof JComponent) {
                JComponent childComponent = (JComponent) child;
                boolean found = false;
                for (int k=0; k<this.componentsAllwaysEnabled.size(); k++) {
                    if (childComponent == this.componentsAllwaysEnabled.get(k)) {
                        found = true;
                    }
                }
                if (!found) {
                    // add the component in the stack to be enabled/disabled
                    stack.push(childComponent);
                }
            }
        }
    }
}
 
源代码16 项目: PyramidShader   文件: ColorPicker.java
private static void setOpaque(JComponent jc,boolean opaque) {
	if(jc instanceof JTextField)
		return;
	
	jc.setOpaque(false);
	if(jc instanceof JSpinner)
		return;
	
	for(int a = 0; a<jc.getComponentCount(); a++) {
		JComponent child = (JComponent)jc.getComponent(a);
		setOpaque(child,opaque);
	}
}
 
源代码17 项目: pumpernickel   文件: JColorPicker.java
private static void setOpaque(JComponent jc, boolean opaque) {
	if (jc instanceof JTextField)
		return;

	jc.setOpaque(false);
	if (jc instanceof JSpinner)
		return;

	for (int a = 0; a < jc.getComponentCount(); a++) {
		JComponent child = (JComponent) jc.getComponent(a);
		setOpaque(child, opaque);
	}
}
 
源代码18 项目: pumpernickel   文件: BreadCrumbUI.java
@Override
protected Collection<JComponent> getEmphasizedComponents(
		JComponent container) {
	Collection<JComponent> returnValue = super
			.getEmphasizedComponents(container);
	if (returnValue.isEmpty()) {
		// when the super has nothing to emphasize, try to emphasize
		// the last thing the user touched. For ex: if they rolled
		// the mouse over a label and then left the container, keep
		// the last thing they rolled over emphasized, just for
		// continuity.
		List<JComponent> lastEmphasized = (List<JComponent>) container
				.getClientProperty(PROPERTY_LAST_EMPHASIZED);
		if (lastEmphasized != null) {
			returnValue = new ArrayList<>();
			List children = Arrays.asList(container.getComponents());
			for (JComponent jc : lastEmphasized) {
				if (children.contains(jc)) {
					returnValue.add(jc);
				}
			}
		}

		// if that failed, grab the last node in the path.
		if (returnValue.isEmpty() && container.getComponentCount() > 0) {
			JComponent last = (JComponent) container
					.getComponent(container.getComponentCount() - 1);
			returnValue = Arrays.asList(last);
		}
	}
	container.putClientProperty(PROPERTY_LAST_EMPHASIZED,
			new ArrayList<>(returnValue));
	return returnValue;
}
 
源代码19 项目: magarena   文件: MagicStyle.java
public static void refreshComponentStyle(final JComponent container) {
    for (Component component : container.getComponents()) {
        if (component instanceof JComponent) {
            final JComponent widget = (JComponent)component;
            if (widget.getComponentCount() > 0) {
                refreshComponentStyle(widget);
            }
            if (widget instanceof IThemeStyle) {
                ((IThemeStyle)widget).refreshStyle();
            }
        }
    }
}
 
源代码20 项目: netbeans   文件: DropTargetLayer.java
private boolean isLastChild(JComponent child, JComponent parent) {
    if(parent == null) return false;
    if(parent.getComponentCount() < 1) return false;
    return (child == parent.getComponent(parent.getComponentCount()-1));
}