public Component getNamedComponent(String name) { if (name == null) { throw new IllegalArgumentException(); } Component namedComponent = null; for (Component component : this) { if (name.equals(component.getName())) { namedComponent = component; break; } } return namedComponent; }
/** * Propagates clear operation to subcomponents. */ @Override public void clear() { for (Component component : components) { component.clear(); } }
@Override protected void processFocusEvent(FocusEvent event) { super.processFocusEvent(event); switch(event.getID()) { case FocusEvent.FOCUS_GAINED: { if (focusedComponent != null && focusedComponent.isShowing() && !focusedComponent.isBlocked()) { focusedComponent.requestFocus(); } break; } case FocusEvent.FOCUS_LOST: { focusedComponent = Component.getFocusedComponent(); Component.clearFocus(); break; } } }
/** * Sets the component's enabled state. Enabled components respond to user * input events; disabled components do not. * * @param enabled * <tt>true</tt> if the component is enabled; <tt>false</tt>, otherwise. */ public void setEnabled(boolean enabled) { if (this.enabled != enabled) { if (!enabled) { // If this component has the focus, clear it if (isFocused()) { clearFocus(); } // Ensure that the mouse out event is processed if (isMouseOver()) { mouseOut(); } } this.enabled = enabled; componentStateListeners.enabledChanged(this); } }
@Override public void update() { int width = component.getWidth(); int height = component.getHeight(); int baseline = component.getBaseline(width, height); int y; Color color; if (baseline == -1) { y = height / 2; color = Color.BLUE; } else { y = baseline; color = Color.RED; } graphics.setPaint(color); GraphicsUtilities.drawLine(graphics, 0, y, width, Orientation.HORIZONTAL); component = null; graphics = null; }
if (component.isVisible()) { int componentWidth = component.getPreferredWidth(clientHeight); baseline = Math.max(baseline, component.getBaseline(componentWidth, clientHeight)); if (component.isVisible()) { Dimensions size; size = new Dimensions(clientWidth, component.getPreferredHeight(clientWidth)); baseline = component.getBaseline(size.width, size.height); if (baseline != -1) { baseline += contentHeight;
@Override public void install(Component componentArgument) { assert(this.component == null) : "Skin is already installed on a component."; componentArgument.getComponentListeners().add(this); componentArgument.getComponentStateListeners().add(this); componentArgument.getComponentMouseListeners().add(this); componentArgument.getComponentMouseButtonListeners().add(this); componentArgument.getComponentMouseWheelListeners().add(this); componentArgument.getComponentKeyListeners().add(this); componentArgument.getComponentTooltipListeners().add(this); this.component = componentArgument; }
Component component = flowPane.get(i); if (component.isVisible()) { Dimensions componentSize = component.getPreferredSize(); component.setSize(componentSize); int baseline = -1; for (Component component : row) { rowWidth += component.getWidth(); rowHeight = Math.max(rowHeight, component.getHeight()); baseline = Math.max(baseline, component.getBaseline(component.getWidth(), component.getHeight())); int componentBaseline = component.getBaseline(component.getWidth(), component.getHeight()); if (alignToBaseline && baseline != -1 } else { y = rowHeight - component.getHeight(); component.setLocation(x, y + rowY); x += (component.getWidth() + horizontalSpacing);
if (isFocused()) { clearFocus(); if (isMouseOver()) { mouseOut(); parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds()); validate();
Component component = get(i); if (component.isVisible() && component.isOpaque() && component.getBounds().contains(paintBounds)) { paintContainer = false; break; super.paint(containerGraphics); containerGraphics.dispose(); Bounds decoratedBounds = component.getDecoratedBounds(); if (component.isVisible() && decoratedBounds.intersects(paintBounds)) { Bounds componentBounds = component.getBounds(); DecoratorSequence decorators = component.getDecorators(); int n = decorators.getLength(); for (int j = n - 1; j >= 0; j--) { component.paint(componentGraphics); componentGraphics.dispose();
@Override public int getBaseline(int width, int height) { FlowPane flowPane = (FlowPane)getComponent(); int baseline = -1; if (alignToBaseline) { int contentWidth = Math.max(width - (padding.left + padding.right), 0); // Break the components into multiple rows, and calculate the baseline of the // first row int rowWidth = 0; for (int i = 0, n = flowPane.getLength(); i < n; i++) { Component component = flowPane.get(i); if (component.isVisible()) { Dimensions size = component.getPreferredSize(); if (rowWidth + size.width > contentWidth && rowWidth > 0) { // The component is too big to fit in the remaining space, // and it is not the only component in this row; wrap break; } baseline = Math.max(baseline, component.getBaseline(size.width, size.height)); rowWidth += size.width + horizontalSpacing; } } // Include top padding value baseline += padding.top; } return baseline; }
/** * Finds the {@link Form.Section} that the given component belongs to. * Only finds the section if the component is a direct child of the section. * * @see #getEnclosingSection getEnclosingSection(Component) */ public static Section getSection(Component component) { return (Section)component.getAttribute(Attribute.SECTION); }
rowHeaderWidth = rowHeader.getPreferredWidth(-1); clientWidth -= rowHeaderWidth; columnHeaderHeight = columnHeader.getPreferredHeight(-1); clientHeight -= columnHeaderHeight; baseline = columnHeader.getBaseline(clientWidth, columnHeaderHeight); baseline = rowHeader.getBaseline(rowHeaderWidth, clientHeight); baseline = view.getBaseline(clientWidth, clientHeight);
&& component.isVisible()) { int columnSpan = Math.min(TablePane.getColumnSpan(component), columnCount - j); int componentWidth = (columnSpan - 1) * horizontalSpacing; baseline = component.getBaseline(Math.max(componentWidth, 0), Math.max(componentHeight, 0));
protected void setParent(Container parent) { // If this component is being removed from the component hierarchy // and is currently focused, clear the focus if (parent == null && isFocused()) { clearFocus(); } Container previousParent = this.parent; this.parent = parent; if (previousParent != null) { previousParent.descendantRemoved(this); } if (parent != null) { parent.descendantAdded(this); } componentListeners.parentChanged(this, previousParent); }
public Component getComponentAt(int x, int y) { assertEventDispatchThread(); Component component = null; int i = components.getLength() - 1; while (i >= 0) { component = components.get(i); if (component.isVisible()) { Bounds bounds = component.getBounds(); if (bounds.contains(x, y)) { break; } } i--; } if (i < 0) { component = null; } return component; }
/** * Finds the {@link Form.Section} that the given component belongs to. * Will search up the parent hierarchy in case the component is nested inside * other containers inside the form. * * @return * The form section this component (or one of its parents) belongs to or * <code>null</code> if the component does not belong to a form. * * @see #getSection getSection(Component) */ public static Section getEnclosingSection(Component component) { Section section = (Section)component.getAttribute(Attribute.SECTION); if (section == null) { for (Container parent = component.getParent(); parent != null && (section = (Section)parent.getAttribute(Attribute.SECTION)) == null; ) { parent = parent.getParent(); } } return section; }
public Window getWindow() { return (Window)getAncestor(Window.class); }
@Override public int getBaseline(int width, int height) { int baseline = -1; if (sizeToSelection) { CardPane cardPane = (CardPane)getComponent(); Component selectedCard = cardPane.getSelectedCard(); if (selectedCard != null) { int cardWidth = Math.max(width - (padding.left + padding.right), 0); int cardHeight = Math.max(height - (padding.top + padding.bottom), 0); baseline = selectedCard.getBaseline(cardWidth, cardHeight); if (baseline != -1) { baseline += padding.top; } } } return baseline; }
@Override protected void descendantRemoved(Component descendant) { super.descendantRemoved(descendant); String automationID = descendant.getAutomationID(); if (automationID != null) { Automation.remove(automationID); } }