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

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

源代码1 项目: pumpernickel   文件: MockComponent.java
/**
 * Temporarily massage this component so it is visible, enabled, unselected,
 * unfocused, etc.
 */
private void storeState(JComponent c) {
	if (c instanceof AbstractButton) {
		AbstractButton b = (AbstractButton) c;
		b.putClientProperty(WAS_SELECTED, new Boolean(b.isSelected()));
		b.putClientProperty(WAS_FOCUS_PAINTED, new Boolean(b.isSelected()));
		b.setSelected(false);
		b.setFocusPainted(false);
	}
	if (c.isEnabled() == false) {
		c.putClientProperty(WAS_ENABLED, new Boolean(c.isEnabled()));
		c.setEnabled(true);
	}
	if (c.isVisible() == false) {
		c.putClientProperty(WAS_VISIBLE, new Boolean(c.isVisible()));
		c.setVisible(true);
	}
	for (int a = 0; a < c.getComponentCount(); a++) {
		if (c.getComponent(a) instanceof JComponent) {
			storeState((JComponent) c.getComponent(a));
		}
	}
}
 
源代码2 项目: littleluck   文件: LuckOptionPaneUI.java
/**
 * 重写该方法,设置内容显示区域为不完全透明
 */
@Override
protected Container createMessageArea()
{
    JComponent messageArea = (JComponent) super.createMessageArea();

    messageArea.setOpaque(false);

    JComponent realBody = (JComponent) messageArea.getComponent(0);

    realBody.setOpaque(false);

    for(Component child : realBody.getComponents())
    {
        ((JComponent)child).setOpaque(false);
    }

    return messageArea;
}
 
源代码3 项目: 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);
      }
    }
  }
}
 
源代码4 项目: 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);

}
 
源代码5 项目: 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);
}
 
源代码6 项目: 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);
    }
}
 
源代码7 项目: 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);
    }
}
 
源代码8 项目: 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 );
	}
}
 
源代码9 项目: visualvm   文件: SnapshotDiffView.java
public DataViewComponent.MasterView getMasterView() {
    try {
        JComponent memoryDiffPanel = (JComponent)sdw.getComponent(0);
        memoryDiffPanel.setOpaque(false);
        final JToolBar toolBar = (JToolBar)memoryDiffPanel.getComponent(1);
        toolBar.setOpaque(false);
        ((JComponent)toolBar.getComponent(0)).setOpaque(false);
        ((JComponent)toolBar.getComponent(1)).setOpaque(false);
        ((JComponent)toolBar.getComponent(3)).setOpaque(false);
        ((JComponent)toolBar.getComponent(4)).setOpaque(false);
        ((JComponent)toolBar.getComponent(5)).setOpaque(false);

        JPanel toolbarSpacer = new JPanel(null) {
            public Dimension getPreferredSize() {
                if (UISupport.isGTKLookAndFeel() || UISupport.isNimbusLookAndFeel()) {
                    int currentWidth = toolBar.getSize().width;
                    int minimumWidth = toolBar.getMinimumSize().width;
                    int extraWidth = currentWidth - minimumWidth;
                    return new Dimension(Math.max(extraWidth, 0), 0);
                } else {
                    return super.getPreferredSize();
                }
            }
        };
        toolbarSpacer.setOpaque(false);
        Component descriptionLabel = toolBar.getComponent(7);
        toolBar.remove(descriptionLabel);
        toolBar.remove(6);
        toolBar.add(toolbarSpacer);
        toolBar.add(descriptionLabel);
    } catch (Exception e) {}

    sdw.setPreferredSize(new Dimension(1, 1));
    SnapshotDiffContainer snapshotDiff = (SnapshotDiffContainer)getDataSource();
    String caption = NbBundle.getMessage(SnapshotDiffView.class, "DESCR_Snapshots_Comparison", // NOI18N
            new Object[] { DataSourceDescriptorFactory.getDescriptor(snapshotDiff.getSnapshot1()).getName(),
                           DataSourceDescriptorFactory.getDescriptor(snapshotDiff.getSnapshot2()).getName()});
    return new DataViewComponent.MasterView(caption, null, sdw);   // NOI18N
}
 
源代码10 项目: 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);
		}
	}
}
 
源代码11 项目: 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;
}
 
源代码12 项目: 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);
		}
	}
}
 
源代码13 项目: pumpernickel   文件: MockComponent.java
/** Restore this component back to its original goodness. */
private void restoreState(JComponent c) {
	if (c instanceof AbstractButton) {
		AbstractButton b = (AbstractButton) c;
		if (b.getClientProperty(WAS_SELECTED) != null) {
			b.setSelected(((Boolean) b.getClientProperty(WAS_SELECTED))
					.booleanValue());
			b.putClientProperty(WAS_SELECTED, null);
		}
		if (b.getClientProperty(WAS_FOCUS_PAINTED) != null) {
			b.setFocusPainted(((Boolean) b
					.getClientProperty(WAS_FOCUS_PAINTED)).booleanValue());
			b.putClientProperty(WAS_FOCUS_PAINTED, null);
		}
	}
	if (c.getClientProperty(WAS_ENABLED) != null) {
		c.setEnabled(((Boolean) c.getClientProperty(WAS_ENABLED))
				.booleanValue());
		c.putClientProperty(WAS_ENABLED, null);
	}
	if (c.getClientProperty(WAS_VISIBLE) != null) {
		c.setVisible(((Boolean) c.getClientProperty(WAS_VISIBLE))
				.booleanValue());
		c.putClientProperty(WAS_VISIBLE, null);
	}
	for (int a = 0; a < c.getComponentCount(); a++) {
		if (c.getComponent(a) instanceof JComponent) {
			restoreState((JComponent) c.getComponent(a));
		}
	}
}
 
源代码14 项目: 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);
	}
}
 
源代码15 项目: 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;
}
 
源代码16 项目: sldeditor   文件: IntegerSpinner.java
/** Instantiates a new value spinner. */
public IntegerSpinner(int min, int max, int stepSize) {
    SpinnerNumberModel model = new SpinnerNumberModel(min, min, max, stepSize);
    setModel(model);

    JComponent comp = getEditor();
    final JFormattedTextField field = (JFormattedTextField) comp.getComponent(0);
    DefaultFormatter formatter = (DefaultFormatter) field.getFormatter();
    formatter.setCommitsOnValidEdit(true);
    addChangeListener(
            new ChangeListener() {
                private double oldValue = Double.MAX_VALUE;

                @Override
                public void stateChanged(ChangeEvent e) {

                    Double doubleValue = IntegerSpinner.this.getDoubleValue();

                    if (doubleValue != oldValue) {
                        double oldValueCopy = oldValue;

                        oldValue = doubleValue;
                        if (minIsZero && (doubleValue < 0.0)) {
                            doubleValue = 0.0;
                            field.setValue(doubleValue);
                        }

                        notifyListeners(oldValueCopy, doubleValue);
                    }
                }
            });
}
 
源代码17 项目: 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);
	}
}
 
源代码18 项目: 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);
                }
            }
        }
    }
}
 
源代码19 项目: 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));
}