jcomponent.java
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 2,217 行 · 第 1/5 页
JAVA
2,217 行
*/ public int getDebugGraphicsOptions() { return 0; } /** * Get the component's insets, which are calculated from * the {@link #border} property. If the border is <code>null</code>, * calls {@link Container#getInsets}. * * @return The component's current insets */ public Insets getInsets() { if (border == null) return super.getInsets(); return getBorder().getBorderInsets(this); } /** * Get the component's insets, which are calculated from the {@link * #border} property. If the border is <code>null</code>, calls {@link * Container#getInsets}. The passed-in {@link Insets} value will be * used as the return value, if possible. * * @param insets Return value object to reuse, if possible * * @return The component's current insets */ public Insets getInsets(Insets insets) { Insets t = getInsets(); if (insets == null) return t; insets.left = t.left; insets.right = t.right; insets.top = t.top; insets.bottom = t.bottom; return insets; } /** * Get the component's location. The passed-in {@link Point} value * will be used as the return value, if possible. * * @param rv Return value object to reuse, if possible * * @return The component's current location */ public Point getLocation(Point rv) { if (rv == null) return new Point(getX(), getY()); rv.setLocation(getX(), getY()); return rv; } /** * Get the component's maximum size. If the {@link #maximumSize} property * has been explicitly set, it is returned. If the {@link #maximumSize} * property has not been set but the {@link ui} property has been, the * result of {@link ComponentUI#getMaximumSize} is returned. If neither * property has been set, the result of {@link Container#getMaximumSize} * is returned. * * @return The maximum size of the component * * @see #maximumSize * @see #setMaximumSize */ public Dimension getMaximumSize() { if (maximumSize != null) return maximumSize; if (ui != null) { Dimension s = ui.getMaximumSize(this); if (s != null) return s; } Dimension p = super.getMaximumSize(); return p; } /** * Get the component's minimum size. If the {@link #minimumSize} property * has been explicitly set, it is returned. If the {@link #minimumSize} * property has not been set but the {@link ui} property has been, the * result of {@link ComponentUI#getMinimumSize} is returned. If neither * property has been set, the result of {@link Container#getMinimumSize} * is returned. * * @return The minimum size of the component * * @see #minimumSize * @see #setMinimumSize */ public Dimension getMinimumSize() { if (minimumSize != null) return minimumSize; if (ui != null) { Dimension s = ui.getMinimumSize(this); if (s != null) return s; } Dimension p = super.getMinimumSize(); return p; } /** * Get the component's preferred size. If the {@link #preferredSize} * property has been explicitly set, it is returned. If the {@link * #preferredSize} property has not been set but the {@link ui} property * has been, the result of {@link ComponentUI#getPreferredSize} is * returned. If neither property has been set, the result of {@link * Container#getPreferredSize} is returned. * * @return The preferred size of the component * * @see #preferredSize * @see #setPreferredSize */ public Dimension getPreferredSize() { if (preferredSize != null) return preferredSize; if (ui != null) { Dimension s = ui.getPreferredSize(this); if (s != null) return s; } Dimension p = super.getPreferredSize(); return p; } /** * Checks if a maximum size was explicitely set on the component. * * @return <code>true</code> if a maximum size was set, * <code>false</code> otherwise * * @since 1.3 */ public boolean isMaximumSizeSet() { return maximumSize != null; } /** * Checks if a minimum size was explicitely set on the component. * * @return <code>true</code> if a minimum size was set, * <code>false</code> otherwise * * @since 1.3 */ public boolean isMinimumSizeSet() { return minimumSize != null; } /** * Checks if a preferred size was explicitely set on the component. * * @return <code>true</code> if a preferred size was set, * <code>false</code> otherwise * * @since 1.3 */ public boolean isPreferredSizeSet() { return preferredSize != null; } /** * Return the value of the {@link #nextFocusableComponent} property. * * @return The current value of the property, or <code>null</code> * if none has been set. * * @deprecated See {@link java.awt.FocusTraversalPolicy} */ public Component getNextFocusableComponent() { return null; } /** * Return the set of {@link KeyStroke} objects which are registered * to initiate actions on this component. * * @return An array of the registered keystrokes */ public KeyStroke[] getRegisteredKeyStrokes() { return null; } /** * Returns the first ancestor of this component which is a {@link JRootPane}. * Equivalent to calling <code>SwingUtilities.getRootPane(this);</code>. * * @return An ancestral JRootPane, or <code>null</code> if none exists. */ public JRootPane getRootPane() { JRootPane p = SwingUtilities.getRootPane(this); return p; } /** * Get the component's size. The passed-in {@link Dimension} value * will be used as the return value, if possible. * * @param rv Return value object to reuse, if possible * * @return The component's current size */ public Dimension getSize(Dimension rv) { if (rv == null) return new Dimension(getWidth(), getHeight()); else { rv.setSize(getWidth(), getHeight()); return rv; } } /** * Return the {@link #toolTip} property of this component, creating it and * setting it if it is currently <code>null</code>. This method can be * overridden in subclasses which wish to control the exact form of * tooltip created. * * @return The current toolTip */ public JToolTip createToolTip() { JToolTip toolTip = new JToolTip(); toolTip.setComponent(this); toolTip.setTipText(toolTipText); return toolTip; } /** * Return the location at which the {@link #toolTip} property should be * displayed, when triggered by a particular mouse event. * * @param event The event the tooltip is being presented in response to * * @return The point at which to display a tooltip, or <code>null</code> * if swing is to choose a default location. */ public Point getToolTipLocation(MouseEvent event) { return null; } /** * Set the value of the {@link #toolTipText} property. * * @param text The new property value * * @see #getToolTipText */ public void setToolTipText(String text) { if (text == null) { ToolTipManager.sharedInstance().unregisterComponent(this); toolTipText = null; return; } // XXX: The tip text doesn't get updated unless you set it to null // and then to something not-null. This is consistent with the behaviour // of Sun's ToolTipManager. String oldText = toolTipText; toolTipText = text; if (oldText == null) ToolTipManager.sharedInstance().registerComponent(this); } /** * Get the value of the {@link #toolTipText} property. * * @return The current property value * * @see #setToolTipText */ public String getToolTipText() { return toolTipText; } /** * Get the value of the {@link #toolTipText} property, in response to a * particular mouse event. * * @param event The mouse event which triggered the tooltip * * @return The current property value * * @see #setToolTipText */ public String getToolTipText(MouseEvent event) { return getToolTipText(); } /** * Return the top level ancestral container (usually a {@link * java.awt.Window} or {@link java.awt.Applet}) which this component is * contained within, or <code>null</code> if no ancestors exist. * * @return The top level container, if it exists */ public Container getTopLevelAncestor() { Container c = getParent(); for (Container peek = c; peek != null; peek = peek.getParent()) c = peek; return c; } /** * Compute the component's visible rectangle, which is defined * recursively as either the component's bounds, if it has no parent, or * the intersection of the component's bounds with the visible rectangle * of its parent. * * @param rect The return value slot to place the visible rectangle in */ public void computeVisibleRect(Rectangle rect) { Component c = getParent(); if (c != null && c instanceof JComponent) { ((JComponent) c).computeVisibleRect(rect); rect.translate(-getX(), -getY()); Rectangle2D.intersect(rect, new Rectangle(0, 0, getWidth(), getHeight()), rect); } else rect.setRect(0, 0, getWidth(), getHeight()); } /** * Return the component's visible rectangle in a new {@link Rectangle}, * rather than via a return slot. * * @return The component's visible rectangle * * @see #computeVisibleRect(Rectangle) */ public Rectangle getVisibleRect() { Rectangle r = new Rectangle(); computeVisibleRect(r); return r; } /** * <p>Requests that this component receive input focus, giving window * focus to the top level ancestor of this component. Only works on * displayable, focusable, visible components.</p> * * <p>This method should not be called by clients; it is intended for * focus implementations. Use {@link Component#requestFocus} instead.</p> * * @see {@link Component#requestFocus} */ public void grabFocus() { } /** * Get the value of the {@link #doubleBuffered} property. * * @return The property's current value */ public boolean isDoubleBuffered() { return doubleBuffered; } /** * Return <code>true</code> if the provided component has no native peer; * in other words, if it is a "lightweight component". * * @param c The component to test for lightweight-ness * * @return Whether or not the component is lightweight */ public static boolean isLightweightComponent(Component c) { return c.getPeer() instanceof LightweightPeer; } /** * Return <code>true</code> if you wish this component to manage its own * focus. In particular: if you want this component to be sent * <code>TAB</code> and <code>SHIFT+TAB</code> key events, and to not * have its children considered as focus transfer targets. If * <code>true</code>, focus traversal around this component changes to * <code>CTRL+TAB</code> and <code>CTRL+SHIFT+TAB</code>. * * @return <code>true</code> if you want this component to manage its own * focus, otherwise (by default) <code>false</code> * * @deprecated 1.4 Use {@link Component.setFocusTraversalKeys(int,Set)} and * {@link Container.setFocusCycleRoot(boolean)} instead */ public boolean isManagingFocus() { return false; } /** * Return the current value of the {@link opaque} property. * * @return The current property value */ public boolean isOpaque() { return opaque; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?