< prev index next >
src/java.desktop/share/classes/javax/swing/JComponent.java
Print this page
*** 62,86 ****
import sun.swing.SwingUtilities2;
import sun.swing.UIClientPropertyKey;
/**
* The base class for all Swing components except top-level containers.
! * To use a component that inherits from <code>JComponent</code>,
* you must place the component in a containment hierarchy
* whose root is a top-level Swing container.
* Top-level Swing containers --
! * such as <code>JFrame</code>, <code>JDialog</code>,
! * and <code>JApplet</code> --
* are specialized components
* that provide a place for other Swing components to paint themselves.
* For an explanation of containment hierarchies, see
* <a
href="http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html">Swing Components and the Containment Hierarchy</a>,
* a section in <em>The Java Tutorial</em>.
*
* <p>
! * The <code>JComponent</code> class provides:
* <ul>
* <li>The base class for both standard and custom components
* that use the Swing architecture.
* <li>A "pluggable look and feel" (L&F) that can be specified by the
* programmer or (optionally) selected by the user at runtime.
--- 62,86 ----
import sun.swing.SwingUtilities2;
import sun.swing.UIClientPropertyKey;
/**
* The base class for all Swing components except top-level containers.
! * To use a component that inherits from {@code JComponent},
* you must place the component in a containment hierarchy
* whose root is a top-level Swing container.
* Top-level Swing containers --
! * such as {@code JFrame}, {@code JDialog},
! * and {@code JApplet} --
* are specialized components
* that provide a place for other Swing components to paint themselves.
* For an explanation of containment hierarchies, see
* <a
href="http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html">Swing Components and the Containment Hierarchy</a>,
* a section in <em>The Java Tutorial</em>.
*
* <p>
! * The {@code JComponent} class provides:
* <ul>
* <li>The base class for both standard and custom components
* that use the Swing architecture.
* <li>A "pluggable look and feel" (L&F) that can be specified by the
* programmer or (optionally) selected by the user at runtime.
*** 104,123 ****
* href="http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html">How
* to Use Tool Tips</a>
* in <em>The Java Tutorial</em>
* for more information.
* <li>Support for accessibility.
! * <code>JComponent</code> contains all of the methods in the
! * <code>Accessible</code> interface,
* but it doesn't actually implement the interface. That is the
* responsibility of the individual classes
! * that extend <code>JComponent</code>.
* <li>Support for component-specific properties.
* With the {@link #putClientProperty}
* and {@link #getClientProperty} methods,
* you can associate name-object pairs
! * with any object that descends from <code>JComponent</code>.
* <li>An infrastructure for painting
* that includes double buffering and support for borders.
* For more information see <a
* href="http://www.oracle.com/technetwork/java/painting-140037.html#swing">Painting</a> and
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html">How
--- 104,123 ----
* href="http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html">How
* to Use Tool Tips</a>
* in <em>The Java Tutorial</em>
* for more information.
* <li>Support for accessibility.
! * {@code JComponent} contains all of the methods in the
! * {@code Accessible} interface,
* but it doesn't actually implement the interface. That is the
* responsibility of the individual classes
! * that extend {@code JComponent}.
* <li>Support for component-specific properties.
* With the {@link #putClientProperty}
* and {@link #getClientProperty} methods,
* you can associate name-object pairs
! * with any object that descends from {@code JComponent}.
* <li>An infrastructure for painting
* that includes double buffering and support for borders.
* For more information see <a
* href="http://www.oracle.com/technetwork/java/painting-140037.html#swing">Painting</a> and
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/border.html">How
*** 127,147 ****
* For more information on these subjects, see the
* <a href="package-summary.html#package_description">Swing package description</a>
* and <em>The Java Tutorial</em> section
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/jcomponent.html">The JComponent Class</a>.
* <p>
! * <code>JComponent</code> and its subclasses document default values
! * for certain properties. For example, <code>JTable</code> documents the
! * default row height as 16. Each <code>JComponent</code> subclass
! * that has a <code>ComponentUI</code> will create the
! * <code>ComponentUI</code> as part of its constructor. In order
* to provide a particular look and feel each
! * <code>ComponentUI</code> may set properties back on the
! * <code>JComponent</code> that created it. For example, a custom
! * look and feel may require <code>JTable</code>s to have a row
* height of 24. The documented defaults are the value of a property
! * BEFORE the <code>ComponentUI</code> has been installed. If you
* need a specific value for a particular property you should
* explicitly set it.
* <p>
* In release 1.4, the focus subsystem was rearchitected.
* For more information, see
--- 127,147 ----
* For more information on these subjects, see the
* <a href="package-summary.html#package_description">Swing package description</a>
* and <em>The Java Tutorial</em> section
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/jcomponent.html">The JComponent Class</a>.
* <p>
! * {@code JComponent} and its subclasses document default values
! * for certain properties. For example, {@code JTable} documents the
! * default row height as 16. Each {@code JComponent} subclass
! * that has a {@code ComponentUI} will create the
! * {@code ComponentUI} as part of its constructor. In order
* to provide a particular look and feel each
! * {@code ComponentUI} may set properties back on the
! * {@code JComponent} that created it. For example, a custom
! * look and feel may require {@code JTable}s to have a row
* height of 24. The documented defaults are the value of a property
! * BEFORE the {@code ComponentUI} has been installed. If you
* need a specific value for a particular property you should
* explicitly set it.
* <p>
* In release 1.4, the focus subsystem was rearchitected.
* For more information, see
*** 158,168 ****
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see KeyStroke
* @see Action
* @see #setBorder
--- 158,168 ----
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see KeyStroke
* @see Action
* @see #setBorder
*** 254,288 ****
private InputVerifier inputVerifier = null;
private boolean verifyInputWhenFocusTarget = true;
/**
! * Set in <code>_paintImmediately</code>.
* Will indicate the child that initiated the painting operation.
! * If <code>paintingChild</code> is opaque, no need to paint
! * any child components after <code>paintingChild</code>.
! * Test used in <code>paintChildren</code>.
*/
transient Component paintingChild;
/**
! * Constant used for <code>registerKeyboardAction</code> that
* means that the command should be invoked when
* the component has the focus.
*/
public static final int WHEN_FOCUSED = 0;
/**
! * Constant used for <code>registerKeyboardAction</code> that
* means that the command should be invoked when the receiving
* component is an ancestor of the focused component or is
* itself the focused component.
*/
public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT = 1;
/**
! * Constant used for <code>registerKeyboardAction</code> that
* means that the command should be invoked when
* the receiving component is in the window that has the focus
* or is itself the focused component.
*/
public static final int WHEN_IN_FOCUSED_WINDOW = 2;
--- 254,288 ----
private InputVerifier inputVerifier = null;
private boolean verifyInputWhenFocusTarget = true;
/**
! * Set in {@code _paintImmediately}.
* Will indicate the child that initiated the painting operation.
! * If {@code paintingChild} is opaque, no need to paint
! * any child components after {@code paintingChild}.
! * Test used in {@code paintChildren}.
*/
transient Component paintingChild;
/**
! * Constant used for {@code registerKeyboardAction} that
* means that the command should be invoked when
* the component has the focus.
*/
public static final int WHEN_FOCUSED = 0;
/**
! * Constant used for {@code registerKeyboardAction} that
* means that the command should be invoked when the receiving
* component is an ancestor of the focused component or is
* itself the focused component.
*/
public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT = 1;
/**
! * Constant used for {@code registerKeyboardAction} that
* means that the command should be invoked when
* the receiving component is in the window that has the focus
* or is itself the focused component.
*/
public static final int WHEN_IN_FOCUSED_WINDOW = 2;
*** 291,307 ****
* Constant used by some of the APIs to mean that no condition is defined.
*/
public static final int UNDEFINED_CONDITION = -1;
/**
! * The key used by <code>JComponent</code> to access keyboard bindings.
*/
private static final String KEYBOARD_BINDINGS_KEY = "_KeyboardBindings";
/**
! * An array of <code>KeyStroke</code>s used for
! * <code>WHEN_IN_FOCUSED_WINDOW</code> are stashed
* in the client properties under this string.
*/
private static final String WHEN_IN_FOCUSED_WINDOW_BINDINGS = "_WhenInFocusedWindow";
/**
--- 291,307 ----
* Constant used by some of the APIs to mean that no condition is defined.
*/
public static final int UNDEFINED_CONDITION = -1;
/**
! * The key used by {@code JComponent} to access keyboard bindings.
*/
private static final String KEYBOARD_BINDINGS_KEY = "_KeyboardBindings";
/**
! * An array of {@code KeyStroke}s used for
! * {@code WHEN_IN_FOCUSED_WINDOW} are stashed
* in the client properties under this string.
*/
private static final String WHEN_IN_FOCUSED_WINDOW_BINDINGS = "_WhenInFocusedWindow";
/**
*** 311,321 ****
public static final String TOOL_TIP_TEXT_KEY = "ToolTipText";
private static final String NEXT_FOCUS = "nextFocus";
/**
! * <code>JPopupMenu</code> assigned to this component
* and all of its children
*/
private JPopupMenu popupMenu;
/** Private flags **/
--- 311,321 ----
public static final String TOOL_TIP_TEXT_KEY = "ToolTipText";
private static final String NEXT_FOCUS = "nextFocus";
/**
! * {@code JPopupMenu} assigned to this component
* and all of its children
*/
private JPopupMenu popupMenu;
/** Private flags **/
*** 355,369 ****
/**
* Temporary rectangles.
*/
private static java.util.List<Rectangle> tempRectangles = new java.util.ArrayList<Rectangle>(11);
! /** Used for <code>WHEN_FOCUSED</code> bindings. */
private InputMap focusInputMap;
! /** Used for <code>WHEN_ANCESTOR_OF_FOCUSED_COMPONENT</code> bindings. */
private InputMap ancestorInputMap;
! /** Used for <code>WHEN_IN_FOCUSED_KEY</code> bindings. */
private ComponentInputMap windowInputMap;
/** ActionMap. */
private ActionMap actionMap;
--- 355,369 ----
/**
* Temporary rectangles.
*/
private static java.util.List<Rectangle> tempRectangles = new java.util.ArrayList<Rectangle>(11);
! /** Used for {@code WHEN_FOCUSED} bindings. */
private InputMap focusInputMap;
! /** Used for {@code WHEN_ANCESTOR_OF_FOCUSED_COMPONENT} bindings. */
private InputMap ancestorInputMap;
! /** Used for {@code WHEN_IN_FOCUSED_KEY} bindings. */
private ComponentInputMap windowInputMap;
/** ActionMap. */
private ActionMap actionMap;
*** 412,422 ****
return (componentObtainingGraphicsFrom == c);
}
}
/**
! * Returns the Set of <code>KeyStroke</code>s to use if the component
* is managing focus for forward focus traversal.
*/
static Set<KeyStroke> getManagingFocusForwardTraversalKeys() {
synchronized(JComponent.class) {
if (managingFocusForwardTraversalKeys == null) {
--- 412,422 ----
return (componentObtainingGraphicsFrom == c);
}
}
/**
! * Returns the Set of {@code KeyStroke}s to use if the component
* is managing focus for forward focus traversal.
*/
static Set<KeyStroke> getManagingFocusForwardTraversalKeys() {
synchronized(JComponent.class) {
if (managingFocusForwardTraversalKeys == null) {
*** 428,438 ****
}
return managingFocusForwardTraversalKeys;
}
/**
! * Returns the Set of <code>KeyStroke</code>s to use if the component
* is managing focus for backward focus traversal.
*/
static Set<KeyStroke> getManagingFocusBackwardTraversalKeys() {
synchronized(JComponent.class) {
if (managingFocusBackwardTraversalKeys == null) {
--- 428,438 ----
}
return managingFocusForwardTraversalKeys;
}
/**
! * Returns the Set of {@code KeyStroke}s to use if the component
* is managing focus for backward focus traversal.
*/
static Set<KeyStroke> getManagingFocusBackwardTraversalKeys() {
synchronized(JComponent.class) {
if (managingFocusBackwardTraversalKeys == null) {
*** 465,480 ****
tempRectangles.add(rect);
}
}
/**
! * Sets whether or not <code>getComponentPopupMenu</code> should delegate
! * to the parent if this component does not have a <code>JPopupMenu</code>
* assigned to it.
* <p>
! * The default value for this is false, but some <code>JComponent</code>
! * subclasses that are implemented as a number of <code>JComponent</code>s
* may set this to true.
* <p>
* This is a bound property.
*
* @param value whether or not the JPopupMenu is inherited
--- 465,480 ----
tempRectangles.add(rect);
}
}
/**
! * Sets whether or not {@code getComponentPopupMenu} should delegate
! * to the parent if this component does not have a {@code JPopupMenu}
* assigned to it.
* <p>
! * The default value for this is false, but some {@code JComponent}
! * subclasses that are implemented as a number of {@code JComponent}s
* may set this to true.
* <p>
* This is a bound property.
*
* @param value whether or not the JPopupMenu is inherited
*** 500,518 ****
public boolean getInheritsPopupMenu() {
return getFlag(INHERITS_POPUP_MENU);
}
/**
! * Sets the <code>JPopupMenu</code> for this <code>JComponent</code>.
* The UI is responsible for registering bindings and adding the necessary
! * listeners such that the <code>JPopupMenu</code> will be shown at
! * the appropriate time. When the <code>JPopupMenu</code> is shown
* depends upon the look and feel: some may show it on a mouse event,
* some may enable a key binding.
* <p>
! * If <code>popup</code> is null, and <code>getInheritsPopupMenu</code>
! * returns true, then <code>getComponentPopupMenu</code> will be delegated
* to the parent. This provides for a way to make all child components
* inherit the popupmenu of the parent.
* <p>
* This is a bound property.
*
--- 500,518 ----
public boolean getInheritsPopupMenu() {
return getFlag(INHERITS_POPUP_MENU);
}
/**
! * Sets the {@code JPopupMenu} for this {@code JComponent}.
* The UI is responsible for registering bindings and adding the necessary
! * listeners such that the {@code JPopupMenu} will be shown at
! * the appropriate time. When the {@code JPopupMenu} is shown
* depends upon the look and feel: some may show it on a mouse event,
* some may enable a key binding.
* <p>
! * If {@code popup} is null, and {@code getInheritsPopupMenu}
! * returns true, then {@code getComponentPopupMenu} will be delegated
* to the parent. This provides for a way to make all child components
* inherit the popupmenu of the parent.
* <p>
* This is a bound property.
*
*** 533,550 ****
this.popupMenu = popup;
firePropertyChange("componentPopupMenu", oldPopup, popup);
}
/**
! * Returns <code>JPopupMenu</code> that assigned for this component.
! * If this component does not have a <code>JPopupMenu</code> assigned
! * to it and <code>getInheritsPopupMenu</code> is true, this
! * will return <code>getParent().getComponentPopupMenu()</code> (assuming
* the parent is valid.)
*
! * @return <code>JPopupMenu</code> assigned for this component
! * or <code>null</code> if no popup assigned
* @see #setComponentPopupMenu
* @since 1.5
*/
public JPopupMenu getComponentPopupMenu() {
--- 533,550 ----
this.popupMenu = popup;
firePropertyChange("componentPopupMenu", oldPopup, popup);
}
/**
! * Returns {@code JPopupMenu} that assigned for this component.
! * If this component does not have a {@code JPopupMenu} assigned
! * to it and {@code getInheritsPopupMenu} is true, this
! * will return {@code getParent().getComponentPopupMenu()} (assuming
* the parent is valid.)
*
! * @return {@code JPopupMenu} assigned for this component
! * or {@code null} if no popup assigned
* @see #setComponentPopupMenu
* @since 1.5
*/
public JPopupMenu getComponentPopupMenu() {
*** 571,586 ****
return popupMenu;
}
/**
! * Default <code>JComponent</code> constructor. This constructor does
! * very little initialization beyond calling the <code>Container</code>
* constructor. For example, the initial layout manager is
! * <code>null</code>. It does, however, set the component's locale
* property to the value returned by
! * <code>JComponent.getDefaultLocale</code>.
*
* @see #getDefaultLocale
*/
public JComponent() {
super();
--- 571,586 ----
return popupMenu;
}
/**
! * Default {@code JComponent} constructor. This constructor does
! * very little initialization beyond calling the {@code Container}
* constructor. For example, the initial layout manager is
! * {@code null}. It does, however, set the component's locale
* property to the value returned by
! * {@code JComponent.getDefaultLocale}.
*
* @see #getDefaultLocale
*/
public JComponent() {
super();
*** 601,611 ****
}
/**
* Resets the UI property to a value from the current look and feel.
! * <code>JComponent</code> subclasses must override this method
* like this:
* <pre>
* public void updateUI() {
* setUI((SliderUI)UIManager.getUI(this);
* }
--- 601,611 ----
}
/**
* Resets the UI property to a value from the current look and feel.
! * {@code JComponent} subclasses must override this method
* like this:
* <pre>
* public void updateUI() {
* setUI((SliderUI)UIManager.getUI(this);
* }
*** 627,646 ****
return ui;
}
/**
* Sets the look and feel delegate for this component.
! * <code>JComponent</code> subclasses generally override this method
! * to narrow the argument type. For example, in <code>JSlider</code>:
* <pre>
* public void setUI(SliderUI newUI) {
* super.setUI(newUI);
* }
* </pre>
* <p>
! * Additionally <code>JComponent</code> subclasses must provide a
! * <code>getUI</code> method that returns the correct type. For example:
* <pre>
* public SliderUI getUI() {
* return (SliderUI)ui;
* }
* </pre>
--- 627,646 ----
return ui;
}
/**
* Sets the look and feel delegate for this component.
! * {@code JComponent} subclasses generally override this method
! * to narrow the argument type. For example, in {@code JSlider}:
* <pre>
* public void setUI(SliderUI newUI) {
* super.setUI(newUI);
* }
* </pre>
* <p>
! * Additionally {@code JComponent} subclasses must provide a
! * {@code getUI} method that returns the correct type. For example:
* <pre>
* public SliderUI getUI() {
* return (SliderUI)ui;
* }
* </pre>
*** 704,724 ****
}
}
}
/**
! * Returns the <code>UIDefaults</code> key used to
! * look up the name of the <code>swing.plaf.ComponentUI</code>
* class that defines the look and feel
* for this component. Most applications will never need to
! * call this method. Subclasses of <code>JComponent</code> that support
* pluggable look and feel should override this method to
! * return a <code>UIDefaults</code> key that maps to the
! * <code>ComponentUI</code> subclass that defines their look and feel.
*
! * @return the <code>UIDefaults</code> key for a
! * <code>ComponentUI</code> subclass
* @see UIDefaults#getUI
* @beaninfo
* expert: true
* description: UIClassID
*/
--- 704,724 ----
}
}
}
/**
! * Returns the {@code UIDefaults} key used to
! * look up the name of the {@code swing.plaf.ComponentUI}
* class that defines the look and feel
* for this component. Most applications will never need to
! * call this method. Subclasses of {@code JComponent} that support
* pluggable look and feel should override this method to
! * return a {@code UIDefaults} key that maps to the
! * {@code ComponentUI} subclass that defines their look and feel.
*
! * @return the {@code UIDefaults} key for a
! * {@code ComponentUI} subclass
* @see UIDefaults#getUI
* @beaninfo
* expert: true
* description: UIClassID
*/
*** 727,743 ****
}
/**
* Returns the graphics object used to paint this component.
! * If <code>DebugGraphics</code> is turned on we create a new
! * <code>DebugGraphics</code> object if necessary.
* Otherwise we just configure the
* specified graphics object's foreground and font.
*
! * @param g the original <code>Graphics</code> object
! * @return a <code>Graphics</code> object configured for this component
*/
protected Graphics getComponentGraphics(Graphics g) {
Graphics componentGraphics = g;
if (ui != null && DEBUG_GRAPHICS_LOADED) {
if ((DebugGraphics.debugComponentCount() != 0) &&
--- 727,743 ----
}
/**
* Returns the graphics object used to paint this component.
! * If {@code DebugGraphics} is turned on we create a new
! * {@code DebugGraphics} object if necessary.
* Otherwise we just configure the
* specified graphics object's foreground and font.
*
! * @param g the original {@code Graphics} object
! * @return a {@code Graphics} object configured for this component
*/
protected Graphics getComponentGraphics(Graphics g) {
Graphics componentGraphics = g;
if (ui != null && DEBUG_GRAPHICS_LOADED) {
if ((DebugGraphics.debugComponentCount() != 0) &&
*** 753,786 ****
}
/**
* Calls the UI delegate's paint method, if the UI delegate
! * is non-<code>null</code>. We pass the delegate a copy of the
! * <code>Graphics</code> object to protect the rest of the
* paint code from irrevocable changes
! * (for example, <code>Graphics.translate</code>).
* <p>
* If you override this in a subclass you should not make permanent
! * changes to the passed in <code>Graphics</code>. For example, you
! * should not alter the clip <code>Rectangle</code> or modify the
* transform. If you need to do these operations you may find it
! * easier to create a new <code>Graphics</code> from the passed in
! * <code>Graphics</code> and manipulate it. Further, if you do not
* invoker super's implementation you must honor the opaque property,
* that is
* if this component is opaque, you must completely fill in the background
* in a non-opaque color. If you do not honor the opaque property you
* will likely see visual artifacts.
* <p>
! * The passed in <code>Graphics</code> object might
* have a transform other than the identify transform
* installed on it. In this case, you might get
* unexpected results if you cumulatively apply
* another transform.
*
! * @param g the <code>Graphics</code> object to protect
* @see #paint
* @see ComponentUI
*/
protected void paintComponent(Graphics g) {
if (ui != null) {
--- 753,786 ----
}
/**
* Calls the UI delegate's paint method, if the UI delegate
! * is non-{@code null}. We pass the delegate a copy of the
! * {@code Graphics} object to protect the rest of the
* paint code from irrevocable changes
! * (for example, {@code Graphics.translate}).
* <p>
* If you override this in a subclass you should not make permanent
! * changes to the passed in {@code Graphics}. For example, you
! * should not alter the clip {@code Rectangle} or modify the
* transform. If you need to do these operations you may find it
! * easier to create a new {@code Graphics} from the passed in
! * {@code Graphics} and manipulate it. Further, if you do not
* invoker super's implementation you must honor the opaque property,
* that is
* if this component is opaque, you must completely fill in the background
* in a non-opaque color. If you do not honor the opaque property you
* will likely see visual artifacts.
* <p>
! * The passed in {@code Graphics} object might
* have a transform other than the identify transform
* installed on it. In this case, you might get
* unexpected results if you cumulatively apply
* another transform.
*
! * @param g the {@code Graphics} object to protect
* @see #paint
* @see ComponentUI
*/
protected void paintComponent(Graphics g) {
if (ui != null) {
*** 794,809 ****
}
}
/**
* Paints this component's children.
! * If <code>shouldUseBuffer</code> is true,
* no component ancestor has a buffer and
* the component children can use a buffer if they have one.
* Otherwise, one ancestor has a buffer currently in use and children
* should not use a buffer to paint.
! * @param g the <code>Graphics</code> context in which to paint
* @see #paint
* @see java.awt.Container#paint
*/
protected void paintChildren(Graphics g) {
Graphics sg = g;
--- 794,809 ----
}
}
/**
* Paints this component's children.
! * If {@code shouldUseBuffer} is true,
* no component ancestor has a buffer and
* the component children can use a buffer if they have one.
* Otherwise, one ancestor has a buffer currently in use and children
* should not use a buffer to paint.
! * @param g the {@code Graphics} context in which to paint
* @see #paint
* @see java.awt.Container#paint
*/
protected void paintChildren(Graphics g) {
Graphics sg = g;
*** 939,955 ****
/**
* Paints the component's border.
* <p>
* If you override this in a subclass you should not make permanent
! * changes to the passed in <code>Graphics</code>. For example, you
! * should not alter the clip <code>Rectangle</code> or modify the
* transform. If you need to do these operations you may find it
! * easier to create a new <code>Graphics</code> from the passed in
! * <code>Graphics</code> and manipulate it.
*
! * @param g the <code>Graphics</code> context in which to paint
*
* @see #paint
* @see #setBorder
*/
protected void paintBorder(Graphics g) {
--- 939,955 ----
/**
* Paints the component's border.
* <p>
* If you override this in a subclass you should not make permanent
! * changes to the passed in {@code Graphics}. For example, you
! * should not alter the clip {@code Rectangle} or modify the
* transform. If you need to do these operations you may find it
! * easier to create a new {@code Graphics} from the passed in
! * {@code Graphics} and manipulate it.
*
! * @param g the {@code Graphics} context in which to paint
*
* @see #paint
* @see #setBorder
*/
protected void paintBorder(Graphics g) {
*** 959,973 ****
}
}
/**
! * Calls <code>paint</code>. Doesn't clear the background but see
! * <code>ComponentUI.update</code>, which is called by
! * <code>paintComponent</code>.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #paint
* @see #paintComponent
* @see javax.swing.plaf.ComponentUI
*/
public void update(Graphics g) {
--- 959,973 ----
}
}
/**
! * Calls {@code paint}. Doesn't clear the background but see
! * {@code ComponentUI.update}, which is called by
! * {@code paintComponent}.
*
! * @param g the {@code Graphics} context in which to paint
* @see #paint
* @see #paintComponent
* @see javax.swing.plaf.ComponentUI
*/
public void update(Graphics g) {
*** 975,1001 ****
}
/**
* Invoked by Swing to draw components.
! * Applications should not invoke <code>paint</code> directly,
! * but should instead use the <code>repaint</code> method to
* schedule the component for redrawing.
* <p>
* This method actually delegates the work of painting to three
! * protected methods: <code>paintComponent</code>,
! * <code>paintBorder</code>,
! * and <code>paintChildren</code>. They're called in the order
* listed to ensure that children appear on top of component itself.
* Generally speaking, the component and its children should not
* paint in the insets area allocated to the border. Subclasses can
* just override this method, as always. A subclass that just
* wants to specialize the UI (look and feel) delegate's
! * <code>paint</code> method should just override
! * <code>paintComponent</code>.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #paintComponent
* @see #paintBorder
* @see #paintChildren
* @see #getComponentGraphics
* @see #repaint
--- 975,1001 ----
}
/**
* Invoked by Swing to draw components.
! * Applications should not invoke {@code paint} directly,
! * but should instead use the {@code repaint} method to
* schedule the component for redrawing.
* <p>
* This method actually delegates the work of painting to three
! * protected methods: {@code paintComponent},
! * {@code paintBorder},
! * and {@code paintChildren}. They're called in the order
* listed to ensure that children appear on top of component itself.
* Generally speaking, the component and its children should not
* paint in the insets area allocated to the border. Subclasses can
* just override this method, as always. A subclass that just
* wants to specialize the UI (look and feel) delegate's
! * {@code paint} method should just override
! * {@code paintComponent}.
*
! * @param g the {@code Graphics} context in which to paint
* @see #paintComponent
* @see #paintBorder
* @see #paintChildren
* @see #getComponentGraphics
* @see #repaint
*** 1141,1153 ****
}
}
/**
* Invoke this method to print the component. This method invokes
! * <code>print</code> on the component.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #print
* @see #printComponent
* @see #printBorder
* @see #printChildren
*/
--- 1141,1153 ----
}
}
/**
* Invoke this method to print the component. This method invokes
! * {@code print} on the component.
*
! * @param g the {@code Graphics} context in which to paint
* @see #print
* @see #printComponent
* @see #printBorder
* @see #printChildren
*/
*** 1161,1173 ****
}
}
/**
* Invoke this method to print the component to the specified
! * <code>Graphics</code>. This method will result in invocations
! * of <code>printComponent</code>, <code>printBorder</code> and
! * <code>printChildren</code>. It is recommended that you override
* one of the previously mentioned methods rather than this one if
* your intention is to customize the way printing looks. However,
* it can be useful to override this method should you want to prepare
* state before invoking the superclass behavior. As an example,
* if you wanted to change the component's background color before
--- 1161,1173 ----
}
}
/**
* Invoke this method to print the component to the specified
! * {@code Graphics}. This method will result in invocations
! * of {@code printComponent}, {@code printBorder} and
! * {@code printChildren}. It is recommended that you override
* one of the previously mentioned methods rather than this one if
* your intention is to customize the way printing looks. However,
* it can be useful to override this method should you want to prepare
* state before invoking the superclass behavior. As an example,
* if you wanted to change the component's background color before
*** 1186,1206 ****
* }
* </pre>
* <p>
* Alternatively, or for components that delegate painting to other objects,
* you can query during painting whether or not the component is in the
! * midst of a print operation. The <code>isPaintingForPrint</code> method provides
* this ability and its return value will be changed by this method: to
! * <code>true</code> immediately before rendering and to <code>false</code>
* immediately after. With each change a property change event is fired on
! * this component with the name <code>"paintingForPrint"</code>.
* <p>
* This method sets the component's state such that the double buffer
* will not be used: painting will be done directly on the passed in
! * <code>Graphics</code>.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #printComponent
* @see #printBorder
* @see #printChildren
* @see #isPaintingForPrint
*/
--- 1186,1206 ----
* }
* </pre>
* <p>
* Alternatively, or for components that delegate painting to other objects,
* you can query during painting whether or not the component is in the
! * midst of a print operation. The {@code isPaintingForPrint} method provides
* this ability and its return value will be changed by this method: to
! * {@code true} immediately before rendering and to {@code false}
* immediately after. With each change a property change event is fired on
! * this component with the name {@code "paintingForPrint"}.
* <p>
* This method sets the component's state such that the double buffer
* will not be used: painting will be done directly on the passed in
! * {@code Graphics}.
*
! * @param g the {@code Graphics} context in which to paint
* @see #printComponent
* @see #printBorder
* @see #printChildren
* @see #isPaintingForPrint
*/
*** 1216,1255 ****
}
}
/**
* This is invoked during a printing operation. This is implemented to
! * invoke <code>paintComponent</code> on the component. Override this
* if you wish to add special painting behavior when printing.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #print
* @since 1.3
*/
protected void printComponent(Graphics g) {
paintComponent(g);
}
/**
* Prints this component's children. This is implemented to invoke
! * <code>paintChildren</code> on the component. Override this if you
* wish to print the children differently than painting.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #print
* @since 1.3
*/
protected void printChildren(Graphics g) {
paintChildren(g);
}
/**
* Prints the component's border. This is implemented to invoke
! * <code>paintBorder</code> on the component. Override this if you
* wish to print the border differently that it is painted.
*
! * @param g the <code>Graphics</code> context in which to paint
* @see #print
* @since 1.3
*/
protected void printBorder(Graphics g) {
paintBorder(g);
--- 1216,1255 ----
}
}
/**
* This is invoked during a printing operation. This is implemented to
! * invoke {@code paintComponent} on the component. Override this
* if you wish to add special painting behavior when printing.
*
! * @param g the {@code Graphics} context in which to paint
* @see #print
* @since 1.3
*/
protected void printComponent(Graphics g) {
paintComponent(g);
}
/**
* Prints this component's children. This is implemented to invoke
! * {@code paintChildren} on the component. Override this if you
* wish to print the children differently than painting.
*
! * @param g the {@code Graphics} context in which to paint
* @see #print
* @since 1.3
*/
protected void printChildren(Graphics g) {
paintChildren(g);
}
/**
* Prints the component's border. This is implemented to invoke
! * {@code paintBorder} on the component. Override this if you
* wish to print the border differently that it is painted.
*
! * @param g the {@code Graphics} context in which to paint
* @see #print
* @since 1.3
*/
protected void printBorder(Graphics g) {
paintBorder(g);
*** 1268,1295 ****
public boolean isPaintingTile() {
return getFlag(IS_PAINTING_TILE);
}
/**
! * Returns <code>true</code> if the current painting operation on this
! * component is part of a <code>print</code> operation. This method is
* useful when you want to customize what you print versus what you show
* on the screen.
* <p>
* You can detect changes in the value of this property by listening for
* property change events on this component with name
! * <code>"paintingForPrint"</code>.
* <p>
* Note: This method provides complimentary functionality to that provided
* by other high level Swing printing APIs. However, it deals strictly with
* painting and should not be confused as providing information on higher
* level print processes. For example, a {@link javax.swing.JTable#print()}
* operation doesn't necessarily result in a continuous rendering of the
* full component, and the return value of this method can change multiple
* times during that operation. It is even possible for the component to be
* painted to the screen while the printing process is ongoing. In such a
! * case, the return value of this method is <code>true</code> when, and only
* when, the table is being painted as part of the printing process.
*
* @return true if the current painting operation on this component
* is part of a print operation
* @see #print
--- 1268,1295 ----
public boolean isPaintingTile() {
return getFlag(IS_PAINTING_TILE);
}
/**
! * Returns {@code true} if the current painting operation on this
! * component is part of a {@code print} operation. This method is
* useful when you want to customize what you print versus what you show
* on the screen.
* <p>
* You can detect changes in the value of this property by listening for
* property change events on this component with name
! * {@code "paintingForPrint"}.
* <p>
* Note: This method provides complimentary functionality to that provided
* by other high level Swing printing APIs. However, it deals strictly with
* painting and should not be confused as providing information on higher
* level print processes. For example, a {@link javax.swing.JTable#print()}
* operation doesn't necessarily result in a continuous rendering of the
* full component, and the return value of this method can change multiple
* times during that operation. It is even possible for the component to be
* painted to the screen while the printing process is ongoing. In such a
! * case, the return value of this method is {@code true} when, and only
* when, the table is being painted as part of the printing process.
*
* @return true if the current painting operation on this component
* is part of a print operation
* @see #print
*** 1304,1324 ****
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Changes this <code>JComponent</code>'s focus traversal keys to
* CTRL+TAB and CTRL+SHIFT+TAB. Also prevents
! * <code>SortingFocusTraversalPolicy</code> from considering descendants
* of this JComponent when computing a focus traversal cycle.
*
* @return false
* @see java.awt.Component#setFocusTraversalKeys
* @see SortingFocusTraversalPolicy
* @deprecated As of 1.4, replaced by
! * <code>Component.setFocusTraversalKeys(int, Set)</code> and
! * <code>Container.setFocusCycleRoot(boolean)</code>.
*/
@Deprecated
public boolean isManagingFocus() {
return false;
}
--- 1304,1324 ----
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Changes this {@code JComponent}'s focus traversal keys to
* CTRL+TAB and CTRL+SHIFT+TAB. Also prevents
! * {@code SortingFocusTraversalPolicy} from considering descendants
* of this JComponent when computing a focus traversal cycle.
*
* @return false
* @see java.awt.Component#setFocusTraversalKeys
* @see SortingFocusTraversalPolicy
* @deprecated As of 1.4, replaced by
! * {@code Component.setFocusTraversalKeys(int, Set)} and
! * {@code Container.setFocusCycleRoot(boolean)}.
*/
@Deprecated
public boolean isManagingFocus() {
return false;
}
*** 1367,1389 ****
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Overrides the default <code>FocusTraversalPolicy</code> for this
! * <code>JComponent</code>'s focus traversal cycle by unconditionally
! * setting the specified <code>Component</code> as the next
! * <code>Component</code> in the cycle, and this <code>JComponent</code>
! * as the specified <code>Component</code>'s previous
! * <code>Component</code> in the cycle.
*
! * @param aComponent the <code>Component</code> that should follow this
! * <code>JComponent</code> in the focus traversal cycle
*
* @see #getNextFocusableComponent
* @see java.awt.FocusTraversalPolicy
! * @deprecated As of 1.4, replaced by <code>FocusTraversalPolicy</code>
*/
@Deprecated
public void setNextFocusableComponent(Component aComponent) {
boolean displayable = isDisplayable();
if (displayable) {
--- 1367,1389 ----
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Overrides the default {@code FocusTraversalPolicy} for this
! * {@code JComponent}'s focus traversal cycle by unconditionally
! * setting the specified {@code Component} as the next
! * {@code Component} in the cycle, and this {@code JComponent}
! * as the specified {@code Component}'s previous
! * {@code Component} in the cycle.
*
! * @param aComponent the {@code Component} that should follow this
! * {@code JComponent} in the focus traversal cycle
*
* @see #getNextFocusableComponent
* @see java.awt.FocusTraversalPolicy
! * @deprecated As of 1.4, replaced by {@code FocusTraversalPolicy}
*/
@Deprecated
public void setNextFocusableComponent(Component aComponent) {
boolean displayable = isDisplayable();
if (displayable) {
*** 1400,1475 ****
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Returns the <code>Component</code> set by a prior call to
! * <code>setNextFocusableComponent(Component)</code> on this
! * <code>JComponent</code>.
! *
! * @return the <code>Component</code> that will follow this
! * <code>JComponent</code> in the focus traversal cycle, or
! * <code>null</code> if none has been explicitly specified
*
* @see #setNextFocusableComponent
! * @deprecated As of 1.4, replaced by <code>FocusTraversalPolicy</code>.
*/
@Deprecated
public Component getNextFocusableComponent() {
return (Component)getClientProperty(NEXT_FOCUS);
}
/**
! * Provides a hint as to whether or not this <code>JComponent</code>
* should get focus. This is only a hint, and it is up to consumers that
* are requesting focus to honor this property. This is typically honored
* for mouse operations, but not keyboard operations. For example, look
* and feels could verify this property is true before requesting focus
* during a mouse operation. This would often times be used if you did
! * not want a mouse press on a <code>JComponent</code> to steal focus,
! * but did want the <code>JComponent</code> to be traversable via the
! * keyboard. If you do not want this <code>JComponent</code> focusable at
! * all, use the <code>setFocusable</code> method instead.
* <p>
* Please see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>,
* for more information.
*
* @param requestFocusEnabled indicates whether you want this
! * <code>JComponent</code> to be focusable or not
* @see <a href="../../java/awt/doc-files/FocusSpec.html">Focus Specification</a>
* @see java.awt.Component#setFocusable
*/
public void setRequestFocusEnabled(boolean requestFocusEnabled) {
setFlag(REQUEST_FOCUS_DISABLED, !requestFocusEnabled);
}
/**
! * Returns <code>true</code> if this <code>JComponent</code> should
! * get focus; otherwise returns <code>false</code>.
* <p>
* Please see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>,
* for more information.
*
! * @return <code>true</code> if this component should get focus,
! * otherwise returns <code>false</code>
* @see #setRequestFocusEnabled
* @see <a href="../../java/awt/doc-files/FocusSpec.html">Focus
* Specification</a>
* @see java.awt.Component#isFocusable
*/
public boolean isRequestFocusEnabled() {
return !getFlag(REQUEST_FOCUS_DISABLED);
}
/**
! * Requests that this <code>Component</code> gets the input focus.
* Refer to {@link java.awt.Component#requestFocus()
* Component.requestFocus()} for a complete description of
* this method.
* <p>
* Note that the use of this method is discouraged because
--- 1400,1475 ----
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Returns the {@code Component} set by a prior call to
! * {@code setNextFocusableComponent(Component)} on this
! * {@code JComponent}.
! *
! * @return the {@code Component} that will follow this
! * {@code JComponent} in the focus traversal cycle, or
! * {@code null} if none has been explicitly specified
*
* @see #setNextFocusableComponent
! * @deprecated As of 1.4, replaced by {@code FocusTraversalPolicy}.
*/
@Deprecated
public Component getNextFocusableComponent() {
return (Component)getClientProperty(NEXT_FOCUS);
}
/**
! * Provides a hint as to whether or not this {@code JComponent}
* should get focus. This is only a hint, and it is up to consumers that
* are requesting focus to honor this property. This is typically honored
* for mouse operations, but not keyboard operations. For example, look
* and feels could verify this property is true before requesting focus
* during a mouse operation. This would often times be used if you did
! * not want a mouse press on a {@code JComponent} to steal focus,
! * but did want the {@code JComponent} to be traversable via the
! * keyboard. If you do not want this {@code JComponent} focusable at
! * all, use the {@code setFocusable} method instead.
* <p>
* Please see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>,
* for more information.
*
* @param requestFocusEnabled indicates whether you want this
! * {@code JComponent} to be focusable or not
* @see <a href="../../java/awt/doc-files/FocusSpec.html">Focus Specification</a>
* @see java.awt.Component#setFocusable
*/
public void setRequestFocusEnabled(boolean requestFocusEnabled) {
setFlag(REQUEST_FOCUS_DISABLED, !requestFocusEnabled);
}
/**
! * Returns {@code true} if this {@code JComponent} should
! * get focus; otherwise returns {@code false}.
* <p>
* Please see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>,
* for more information.
*
! * @return {@code true} if this component should get focus,
! * otherwise returns {@code false}
* @see #setRequestFocusEnabled
* @see <a href="../../java/awt/doc-files/FocusSpec.html">Focus
* Specification</a>
* @see java.awt.Component#isFocusable
*/
public boolean isRequestFocusEnabled() {
return !getFlag(REQUEST_FOCUS_DISABLED);
}
/**
! * Requests that this {@code Component} gets the input focus.
* Refer to {@link java.awt.Component#requestFocus()
* Component.requestFocus()} for a complete description of
* this method.
* <p>
* Note that the use of this method is discouraged because
*** 1487,1497 ****
public void requestFocus() {
super.requestFocus();
}
/**
! * Requests that this <code>Component</code> gets the input focus.
* Refer to {@link java.awt.Component#requestFocus(boolean)
* Component.requestFocus(boolean)} for a complete description of
* this method.
* <p>
* Note that the use of this method is discouraged because
--- 1487,1497 ----
public void requestFocus() {
super.requestFocus();
}
/**
! * Requests that this {@code Component} gets the input focus.
* Refer to {@link java.awt.Component#requestFocus(boolean)
* Component.requestFocus(boolean)} for a complete description of
* this method.
* <p>
* Note that the use of this method is discouraged because
*** 1502,1556 ****
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
*
* @param temporary boolean indicating if the focus change is temporary
! * @return <code>false</code> if the focus change request is guaranteed to
! * fail; <code>true</code> if it is likely to succeed
* @see java.awt.Component#requestFocusInWindow()
* @see java.awt.Component#requestFocusInWindow(boolean)
* @since 1.4
*/
public boolean requestFocus(boolean temporary) {
return super.requestFocus(temporary);
}
/**
! * Requests that this <code>Component</code> gets the input focus.
* Refer to {@link java.awt.Component#requestFocusInWindow()
* Component.requestFocusInWindow()} for a complete description of
* this method.
* <p>
* If you would like more information on focus, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
*
! * @return <code>false</code> if the focus change request is guaranteed to
! * fail; <code>true</code> if it is likely to succeed
* @see java.awt.Component#requestFocusInWindow()
* @see java.awt.Component#requestFocusInWindow(boolean)
* @since 1.4
*/
public boolean requestFocusInWindow() {
return super.requestFocusInWindow();
}
/**
! * Requests that this <code>Component</code> gets the input focus.
* Refer to {@link java.awt.Component#requestFocusInWindow(boolean)
* Component.requestFocusInWindow(boolean)} for a complete description of
* this method.
* <p>
* If you would like more information on focus, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
*
* @param temporary boolean indicating if the focus change is temporary
! * @return <code>false</code> if the focus change request is guaranteed to
! * fail; <code>true</code> if it is likely to succeed
* @see java.awt.Component#requestFocusInWindow()
* @see java.awt.Component#requestFocusInWindow(boolean)
* @since 1.4
*/
protected boolean requestFocusInWindow(boolean temporary) {
--- 1502,1556 ----
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
*
* @param temporary boolean indicating if the focus change is temporary
! * @return {@code false} if the focus change request is guaranteed to
! * fail; {@code true} if it is likely to succeed
* @see java.awt.Component#requestFocusInWindow()
* @see java.awt.Component#requestFocusInWindow(boolean)
* @since 1.4
*/
public boolean requestFocus(boolean temporary) {
return super.requestFocus(temporary);
}
/**
! * Requests that this {@code Component} gets the input focus.
* Refer to {@link java.awt.Component#requestFocusInWindow()
* Component.requestFocusInWindow()} for a complete description of
* this method.
* <p>
* If you would like more information on focus, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
*
! * @return {@code false} if the focus change request is guaranteed to
! * fail; {@code true} if it is likely to succeed
* @see java.awt.Component#requestFocusInWindow()
* @see java.awt.Component#requestFocusInWindow(boolean)
* @since 1.4
*/
public boolean requestFocusInWindow() {
return super.requestFocusInWindow();
}
/**
! * Requests that this {@code Component} gets the input focus.
* Refer to {@link java.awt.Component#requestFocusInWindow(boolean)
* Component.requestFocusInWindow(boolean)} for a complete description of
* this method.
* <p>
* If you would like more information on focus, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
*
* @param temporary boolean indicating if the focus change is temporary
! * @return {@code false} if the focus change request is guaranteed to
! * fail; {@code true} if it is likely to succeed
* @see java.awt.Component#requestFocusInWindow()
* @see java.awt.Component#requestFocusInWindow(boolean)
* @since 1.4
*/
protected boolean requestFocusInWindow(boolean temporary) {
*** 1563,1573 ****
* must be displayable, visible, and focusable for the request to be
* granted.
* <p>
* This method is intended for use by focus implementations. Client code
* should not use this method; instead, it should use
! * <code>requestFocusInWindow()</code>.
*
* @see #requestFocusInWindow()
*/
public void grabFocus() {
requestFocus();
--- 1563,1573 ----
* must be displayable, visible, and focusable for the request to be
* granted.
* <p>
* This method is intended for use by focus implementations. Client code
* should not use this method; instead, it should use
! * {@code requestFocusInWindow()}.
*
* @see #requestFocusInWindow()
*/
public void grabFocus() {
requestFocus();
*** 1580,1590 ****
* Cancel button or a scrollbar, which should activate even if the
* input in the current focus owner is not "passed" by the input
* verifier for that component.
*
* @param verifyInputWhenFocusTarget value for the
! * <code>verifyInputWhenFocusTarget</code> property
* @see InputVerifier
* @see #setInputVerifier
* @see #getInputVerifier
* @see #getVerifyInputWhenFocusTarget
*
--- 1580,1590 ----
* Cancel button or a scrollbar, which should activate even if the
* input in the current focus owner is not "passed" by the input
* verifier for that component.
*
* @param verifyInputWhenFocusTarget value for the
! * {@code verifyInputWhenFocusTarget} property
* @see InputVerifier
* @see #setInputVerifier
* @see #getInputVerifier
* @see #getVerifyInputWhenFocusTarget
*
*** 1607,1617 ****
/**
* Returns the value that indicates whether the input verifier for the
* current focus owner will be called before this component requests
* focus.
*
! * @return value of the <code>verifyInputWhenFocusTarget</code> property
*
* @see InputVerifier
* @see #setInputVerifier
* @see #getInputVerifier
* @see #setVerifyInputWhenFocusTarget
--- 1607,1617 ----
/**
* Returns the value that indicates whether the input verifier for the
* current focus owner will be called before this component requests
* focus.
*
! * @return value of the {@code verifyInputWhenFocusTarget} property
*
* @see InputVerifier
* @see #setInputVerifier
* @see #getInputVerifier
* @see #setVerifyInputWhenFocusTarget
*** 1622,1647 ****
return verifyInputWhenFocusTarget;
}
/**
! * Gets the <code>FontMetrics</code> for the specified <code>Font</code>.
*
* @param font the font for which font metrics is to be
* obtained
! * @return the font metrics for <code>font</code>
! * @throws NullPointerException if <code>font</code> is null
* @since 1.5
*/
public FontMetrics getFontMetrics(Font font) {
return SwingUtilities2.getFontMetrics(this, font);
}
/**
* Sets the preferred size of this component.
! * If <code>preferredSize</code> is <code>null</code>, the UI will
* be asked for the preferred size.
* @beaninfo
* preferred: true
* bound: true
* description: The preferred size of the component.
--- 1622,1647 ----
return verifyInputWhenFocusTarget;
}
/**
! * Gets the {@code FontMetrics} for the specified {@code Font}.
*
* @param font the font for which font metrics is to be
* obtained
! * @return the font metrics for {@code font}
! * @throws NullPointerException if {@code font} is null
* @since 1.5
*/
public FontMetrics getFontMetrics(Font font) {
return SwingUtilities2.getFontMetrics(this, font);
}
/**
* Sets the preferred size of this component.
! * If {@code preferredSize} is {@code null}, the UI will
* be asked for the preferred size.
* @beaninfo
* preferred: true
* bound: true
* description: The preferred size of the component.
*** 1650,1666 ****
super.setPreferredSize(preferredSize);
}
/**
! * If the <code>preferredSize</code> has been set to a
! * non-<code>null</code> value just returns it.
! * If the UI delegate's <code>getPreferredSize</code>
! * method returns a non <code>null</code> value then return that;
* otherwise defer to the component's layout manager.
*
! * @return the value of the <code>preferredSize</code> property
* @see #setPreferredSize
* @see ComponentUI
*/
@Transient
public Dimension getPreferredSize() {
--- 1650,1666 ----
super.setPreferredSize(preferredSize);
}
/**
! * If the {@code preferredSize} has been set to a
! * non-{@code null} value just returns it.
! * If the UI delegate's {@code getPreferredSize}
! * method returns a non {@code null} value then return that;
* otherwise defer to the component's layout manager.
*
! * @return the value of the {@code preferredSize} property
* @see #setPreferredSize
* @see ComponentUI
*/
@Transient
public Dimension getPreferredSize() {
*** 1675,1690 ****
}
/**
* Sets the maximum size of this component to a constant
! * value. Subsequent calls to <code>getMaximumSize</code> will always
* return this value; the component's UI will not be asked
! * to compute it. Setting the maximum size to <code>null</code>
* restores the default behavior.
*
! * @param maximumSize a <code>Dimension</code> containing the
* desired maximum allowable size
* @see #getMaximumSize
* @beaninfo
* bound: true
* description: The maximum size of the component.
--- 1675,1690 ----
}
/**
* Sets the maximum size of this component to a constant
! * value. Subsequent calls to {@code getMaximumSize} will always
* return this value; the component's UI will not be asked
! * to compute it. Setting the maximum size to {@code null}
* restores the default behavior.
*
! * @param maximumSize a {@code Dimension} containing the
* desired maximum allowable size
* @see #getMaximumSize
* @beaninfo
* bound: true
* description: The maximum size of the component.
*** 1693,1708 ****
super.setMaximumSize(maximumSize);
}
/**
! * If the maximum size has been set to a non-<code>null</code> value
! * just returns it. If the UI delegate's <code>getMaximumSize</code>
! * method returns a non-<code>null</code> value then return that;
* otherwise defer to the component's layout manager.
*
! * @return the value of the <code>maximumSize</code> property
* @see #setMaximumSize
* @see ComponentUI
*/
@Transient
public Dimension getMaximumSize() {
--- 1693,1708 ----
super.setMaximumSize(maximumSize);
}
/**
! * If the maximum size has been set to a non-{@code null} value
! * just returns it. If the UI delegate's {@code getMaximumSize}
! * method returns a non-{@code null} value then return that;
* otherwise defer to the component's layout manager.
*
! * @return the value of the {@code maximumSize} property
* @see #setMaximumSize
* @see ComponentUI
*/
@Transient
public Dimension getMaximumSize() {
*** 1717,1729 ****
}
/**
* Sets the minimum size of this component to a constant
! * value. Subsequent calls to <code>getMinimumSize</code> will always
* return this value; the component's UI will not be asked
! * to compute it. Setting the minimum size to <code>null</code>
* restores the default behavior.
*
* @param minimumSize the new minimum size of this component
* @see #getMinimumSize
* @beaninfo
--- 1717,1729 ----
}
/**
* Sets the minimum size of this component to a constant
! * value. Subsequent calls to {@code getMinimumSize} will always
* return this value; the component's UI will not be asked
! * to compute it. Setting the minimum size to {@code null}
* restores the default behavior.
*
* @param minimumSize the new minimum size of this component
* @see #getMinimumSize
* @beaninfo
*** 1733,1748 ****
public void setMinimumSize(Dimension minimumSize) {
super.setMinimumSize(minimumSize);
}
/**
! * If the minimum size has been set to a non-<code>null</code> value
! * just returns it. If the UI delegate's <code>getMinimumSize</code>
! * method returns a non-<code>null</code> value then return that; otherwise
* defer to the component's layout manager.
*
! * @return the value of the <code>minimumSize</code> property
* @see #setMinimumSize
* @see ComponentUI
*/
@Transient
public Dimension getMinimumSize() {
--- 1733,1748 ----
public void setMinimumSize(Dimension minimumSize) {
super.setMinimumSize(minimumSize);
}
/**
! * If the minimum size has been set to a non-{@code null} value
! * just returns it. If the UI delegate's {@code getMinimumSize}
! * method returns a non-{@code null} value then return that; otherwise
* defer to the component's layout manager.
*
! * @return the value of the {@code minimumSize} property
* @see #setMinimumSize
* @see ComponentUI
*/
@Transient
public Dimension getMinimumSize() {
*** 1767,1794 ****
public boolean contains(int x, int y) {
return (ui != null) ? ui.contains(this, x, y) : super.contains(x, y);
}
/**
! * Sets the border of this component. The <code>Border</code> object is
* responsible for defining the insets for the component
* (overriding any insets set directly on the component) and
* for optionally rendering any border decorations within the
* bounds of those insets. Borders should be used (rather
* than insets) for creating both decorative and non-decorative
* (such as margins and padding) regions for a swing component.
* Compound borders can be used to nest multiple borders within a
* single component.
* <p>
* Although technically you can set the border on any object
! * that inherits from <code>JComponent</code>, the look and
* feel implementation of many standard Swing components
* doesn't work well with user-set borders. In general,
* when you want to set a border on a standard Swing
! * component other than <code>JPanel</code> or <code>JLabel</code>,
! * we recommend that you put the component in a <code>JPanel</code>
! * and set the border on the <code>JPanel</code>.
* <p>
* This is a bound property.
*
* @param border the border to be rendered for this component
* @see Border
--- 1767,1794 ----
public boolean contains(int x, int y) {
return (ui != null) ? ui.contains(this, x, y) : super.contains(x, y);
}
/**
! * Sets the border of this component. The {@code Border} object is
* responsible for defining the insets for the component
* (overriding any insets set directly on the component) and
* for optionally rendering any border decorations within the
* bounds of those insets. Borders should be used (rather
* than insets) for creating both decorative and non-decorative
* (such as margins and padding) regions for a swing component.
* Compound borders can be used to nest multiple borders within a
* single component.
* <p>
* Although technically you can set the border on any object
! * that inherits from {@code JComponent}, the look and
* feel implementation of many standard Swing components
* doesn't work well with user-set borders. In general,
* when you want to set a border on a standard Swing
! * component other than {@code JPanel} or {@code JLabel},
! * we recommend that you put the component in a {@code JPanel}
! * and set the border on the {@code JPanel}.
* <p>
* This is a bound property.
*
* @param border the border to be rendered for this component
* @see Border
*** 1812,1822 ****
repaint();
}
}
/**
! * Returns the border of this component or <code>null</code> if no
* border is currently set.
*
* @return the border object for this component
* @see #setBorder
*/
--- 1812,1822 ----
repaint();
}
}
/**
! * Returns the border of this component or {@code null} if no
* border is currently set.
*
* @return the border object for this component
* @see #setBorder
*/
*** 1824,1834 ****
return border;
}
/**
* If a border has been set on this component, returns the
! * border's insets; otherwise calls <code>super.getInsets</code>.
*
* @return the value of the insets property
* @see #setBorder
*/
public Insets getInsets() {
--- 1824,1834 ----
return border;
}
/**
* If a border has been set on this component, returns the
! * border's insets; otherwise calls {@code super.getInsets}.
*
* @return the value of the insets property
* @see #setBorder
*/
public Insets getInsets() {
*** 1837,1855 ****
}
return super.getInsets();
}
/**
! * Returns an <code>Insets</code> object containing this component's inset
! * values. The passed-in <code>Insets</code> object will be reused
* if possible.
* Calling methods cannot assume that the same object will be returned,
* however. All existing values within this object are overwritten.
! * If <code>insets</code> is null, this will allocate a new one.
*
! * @param insets the <code>Insets</code> object, which can be reused
! * @return the <code>Insets</code> object
* @see #getInsets
* @beaninfo
* expert: true
*/
public Insets getInsets(Insets insets) {
--- 1837,1855 ----
}
return super.getInsets();
}
/**
! * Returns an {@code Insets} object containing this component's inset
! * values. The passed-in {@code Insets} object will be reused
* if possible.
* Calling methods cannot assume that the same object will be returned,
* however. All existing values within this object are overwritten.
! * If {@code insets} is null, this will allocate a new one.
*
! * @param insets the {@code Insets} object, which can be reused
! * @return the {@code Insets} object
* @see #getInsets
* @beaninfo
* expert: true
*/
public Insets getInsets(Insets insets) {
*** 1871,1884 ****
return insets;
}
}
/**
! * Overrides <code>Container.getAlignmentY</code> to return
* the vertical alignment.
*
! * @return the value of the <code>alignmentY</code> property
* @see #setAlignmentY
* @see java.awt.Component#getAlignmentY
*/
public float getAlignmentY() {
if (isAlignmentYSet) {
--- 1871,1884 ----
return insets;
}
}
/**
! * Overrides {@code Container.getAlignmentY} to return
* the vertical alignment.
*
! * @return the value of the {@code alignmentY} property
* @see #setAlignmentY
* @see java.awt.Component#getAlignmentY
*/
public float getAlignmentY() {
if (isAlignmentYSet) {
*** 1900,1913 ****
isAlignmentYSet = true;
}
/**
! * Overrides <code>Container.getAlignmentX</code> to return
* the horizontal alignment.
*
! * @return the value of the <code>alignmentX</code> property
* @see #setAlignmentX
* @see java.awt.Component#getAlignmentX
*/
public float getAlignmentX() {
if (isAlignmentXSet) {
--- 1900,1913 ----
isAlignmentYSet = true;
}
/**
! * Overrides {@code Container.getAlignmentX} to return
* the horizontal alignment.
*
! * @return the value of the {@code alignmentX} property
* @see #setAlignmentX
* @see java.awt.Component#getAlignmentX
*/
public float getAlignmentX() {
if (isAlignmentXSet) {
*** 1951,1971 ****
}
/**
* Returns the input verifier for this component.
*
! * @return the <code>inputVerifier</code> property
* @since 1.3
* @see InputVerifier
*/
public InputVerifier getInputVerifier() {
return (InputVerifier)getClientProperty(JComponent_INPUT_VERIFIER);
}
/**
* Returns this component's graphics context, which lets you draw
! * on a component. Use this method to get a <code>Graphics</code> object and
* then invoke operations on that object to draw on the component.
* @return this components graphics context
*/
public Graphics getGraphics() {
if (DEBUG_GRAPHICS_LOADED && shouldDebugGraphics() != 0) {
--- 1951,1971 ----
}
/**
* Returns the input verifier for this component.
*
! * @return the {@code inputVerifier} property
* @since 1.3
* @see InputVerifier
*/
public InputVerifier getInputVerifier() {
return (InputVerifier)getClientProperty(JComponent_INPUT_VERIFIER);
}
/**
* Returns this component's graphics context, which lets you draw
! * on a component. Use this method to get a {@code Graphics} object and
* then invoke operations on that object to draw on the component.
* @return this components graphics context
*/
public Graphics getGraphics() {
if (DEBUG_GRAPHICS_LOADED && shouldDebugGraphics() != 0) {
*** 1985,2000 ****
* <ul>
* <li>DebugGraphics.LOG_OPTION - causes a text message to be printed.
* <li>DebugGraphics.FLASH_OPTION - causes the drawing to flash several
* times.
* <li>DebugGraphics.BUFFERED_OPTION - creates an
! * <code>ExternalWindow</code> that displays the operations
* performed on the View's offscreen buffer.
* <li>DebugGraphics.NONE_OPTION disables debugging.
* <li>A value of 0 causes no changes to the debugging options.
* </ul>
! * <code>debugOptions</code> is bitwise OR'd into the current value
*
* @beaninfo
* preferred: true
* enum: NONE_OPTION DebugGraphics.NONE_OPTION
* LOG_OPTION DebugGraphics.LOG_OPTION
--- 1985,2000 ----
* <ul>
* <li>DebugGraphics.LOG_OPTION - causes a text message to be printed.
* <li>DebugGraphics.FLASH_OPTION - causes the drawing to flash several
* times.
* <li>DebugGraphics.BUFFERED_OPTION - creates an
! * {@code ExternalWindow} that displays the operations
* performed on the View's offscreen buffer.
* <li>DebugGraphics.NONE_OPTION disables debugging.
* <li>A value of 0 causes no changes to the debugging options.
* </ul>
! * {@code debugOptions} is bitwise OR'd into the current value
*
* @beaninfo
* preferred: true
* enum: NONE_OPTION DebugGraphics.NONE_OPTION
* LOG_OPTION DebugGraphics.LOG_OPTION
*** 2012,2022 ****
* <ul>
* <li>DebugGraphics.LOG_OPTION - causes a text message to be printed.
* <li>DebugGraphics.FLASH_OPTION - causes the drawing to flash several
* times.
* <li>DebugGraphics.BUFFERED_OPTION - creates an
! * <code>ExternalWindow</code> that displays the operations
* performed on the View's offscreen buffer.
* <li>DebugGraphics.NONE_OPTION disables debugging.
* <li>A value of 0 causes no changes to the debugging options.
* </ul>
* @see #setDebugGraphicsOptions
--- 2012,2022 ----
* <ul>
* <li>DebugGraphics.LOG_OPTION - causes a text message to be printed.
* <li>DebugGraphics.FLASH_OPTION - causes the drawing to flash several
* times.
* <li>DebugGraphics.BUFFERED_OPTION - creates an
! * {@code ExternalWindow} that displays the operations
* performed on the View's offscreen buffer.
* <li>DebugGraphics.NONE_OPTION disables debugging.
* <li>A value of 0 causes no changes to the debugging options.
* </ul>
* @see #setDebugGraphicsOptions
*** 2026,2066 ****
}
/**
* Returns true if debug information is enabled for this
! * <code>JComponent</code> or one of its parents.
*/
int shouldDebugGraphics() {
return DebugGraphics.shouldComponentDebug(this);
}
/**
* This method is now obsolete, please use a combination of
! * <code>getActionMap()</code> and <code>getInputMap()</code> for
! * similar behavior. For example, to bind the <code>KeyStroke</code>
! * <code>aKeyStroke</code> to the <code>Action</code> <code>anAction</code>
* now use:
* <pre>
* component.getInputMap().put(aKeyStroke, aCommand);
* component.getActionMap().put(aCommmand, anAction);
* </pre>
* The above assumes you want the binding to be applicable for
! * <code>WHEN_FOCUSED</code>. To register bindings for other focus
! * states use the <code>getInputMap</code> method that takes an integer.
* <p>
* Register a new keyboard action.
! * <code>anAction</code> will be invoked if a key event matching
! * <code>aKeyStroke</code> occurs and <code>aCondition</code> is verified.
! * The <code>KeyStroke</code> object defines a
* particular combination of a keyboard key and one or more modifiers
* (alt, shift, ctrl, meta).
* <p>
! * The <code>aCommand</code> will be set in the delivered event if
* specified.
* <p>
! * The <code>aCondition</code> can be one of:
* <blockquote>
* <DL>
* <DT>WHEN_FOCUSED
* <DD>The action will be invoked only when the keystroke occurs
* while the component has the focus.
--- 2026,2066 ----
}
/**
* Returns true if debug information is enabled for this
! * {@code JComponent} or one of its parents.
*/
int shouldDebugGraphics() {
return DebugGraphics.shouldComponentDebug(this);
}
/**
* This method is now obsolete, please use a combination of
! * {@code getActionMap()} and {@code getInputMap()} for
! * similar behavior. For example, to bind the {@code KeyStroke}
! * {@code aKeyStroke} to the {@code Action anAction}
* now use:
* <pre>
* component.getInputMap().put(aKeyStroke, aCommand);
* component.getActionMap().put(aCommmand, anAction);
* </pre>
* The above assumes you want the binding to be applicable for
! * {@code WHEN_FOCUSED}. To register bindings for other focus
! * states use the {@code getInputMap} method that takes an integer.
* <p>
* Register a new keyboard action.
! * {@code anAction} will be invoked if a key event matching
! * {@code aKeyStroke} occurs and {@code aCondition} is verified.
! * The {@code KeyStroke} object defines a
* particular combination of a keyboard key and one or more modifiers
* (alt, shift, ctrl, meta).
* <p>
! * The {@code aCommand} will be set in the delivered event if
* specified.
* <p>
! * The {@code aCondition} can be one of:
* <blockquote>
* <DL>
* <DT>WHEN_FOCUSED
* <DD>The action will be invoked only when the keystroke occurs
* while the component has the focus.
*** 2088,2102 ****
* appropriate component in the hierarchy, and cause a specific method
* to be invoked (usually by way of adapter objects).
* <p>
* If an action has already been registered for the receiving
* container, with the same charCode and the same modifiers,
! * <code>anAction</code> will replace the action.
*
! * @param anAction the <code>Action</code> to be registered
* @param aCommand the command to be set in the delivered event
! * @param aKeyStroke the <code>KeyStroke</code> to bind to the action
* @param aCondition the condition that needs to be met, see above
* @see KeyStroke
*/
public void registerKeyboardAction(ActionListener anAction,String aCommand,KeyStroke aKeyStroke,int aCondition) {
--- 2088,2102 ----
* appropriate component in the hierarchy, and cause a specific method
* to be invoked (usually by way of adapter objects).
* <p>
* If an action has already been registered for the receiving
* container, with the same charCode and the same modifiers,
! * {@code anAction} will replace the action.
*
! * @param anAction the {@code Action} to be registered
* @param aCommand the command to be set in the delivered event
! * @param aKeyStroke the {@code KeyStroke} to bind to the action
* @param aCondition the condition that needs to be met, see above
* @see KeyStroke
*/
public void registerKeyboardAction(ActionListener anAction,String aCommand,KeyStroke aKeyStroke,int aCondition) {
*** 2111,2128 ****
}
}
}
/**
! * Registers any bound <code>WHEN_IN_FOCUSED_WINDOW</code> actions with
! * the <code>KeyboardManager</code>. If <code>onlyIfNew</code>
* is true only actions that haven't been registered are pushed
! * to the <code>KeyboardManager</code>;
! * otherwise all actions are pushed to the <code>KeyboardManager</code>.
*
* @param onlyIfNew if true, only actions that haven't been registered
! * are pushed to the <code>KeyboardManager</code>
*/
private void registerWithKeyboardManager(boolean onlyIfNew) {
InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
KeyStroke[] strokes;
@SuppressWarnings("unchecked")
--- 2111,2128 ----
}
}
}
/**
! * Registers any bound {@code WHEN_IN_FOCUSED_WINDOW} actions with
! * the {@code KeyboardManager}. If {@code onlyIfNew}
* is true only actions that haven't been registered are pushed
! * to the {@code KeyboardManager};
! * otherwise all actions are pushed to the {@code KeyboardManager}.
*
* @param onlyIfNew if true, only actions that haven't been registered
! * are pushed to the {@code KeyboardManager}
*/
private void registerWithKeyboardManager(boolean onlyIfNew) {
InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
KeyStroke[] strokes;
@SuppressWarnings("unchecked")
*** 2174,2184 ****
}
}
/**
* Unregisters all the previously registered
! * <code>WHEN_IN_FOCUSED_WINDOW</code> <code>KeyStroke</code> bindings.
*/
private void unregisterWithKeyboardManager() {
@SuppressWarnings("unchecked")
Hashtable<KeyStroke, KeyStroke> registered =
(Hashtable<KeyStroke, KeyStroke>)getClientProperty
--- 2174,2184 ----
}
}
/**
* Unregisters all the previously registered
! * {@code WHEN_IN_FOCUSED_WINDOW KeyStroke} bindings.
*/
private void unregisterWithKeyboardManager() {
@SuppressWarnings("unchecked")
Hashtable<KeyStroke, KeyStroke> registered =
(Hashtable<KeyStroke, KeyStroke>)getClientProperty
*** 2194,2207 ****
}
putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null);
}
/**
! * Invoked from <code>ComponentInputMap</code> when its bindings change.
! * If <code>inputMap</code> is the current <code>windowInputMap</code>
! * (or a parent of the window <code>InputMap</code>)
! * the <code>KeyboardManager</code> is notified of the new bindings.
*
* @param inputMap the map containing the new bindings
*/
void componentInputMapChanged(ComponentInputMap inputMap) {
InputMap km = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
--- 2194,2207 ----
}
putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null);
}
/**
! * Invoked from {@code ComponentInputMap} when its bindings change.
! * If {@code inputMap} is the current {@code windowInputMap}
! * (or a parent of the window {@code InputMap})
! * the {@code KeyboardManager} is notified of the new bindings.
*
* @param inputMap the map containing the new bindings
*/
void componentInputMapChanged(ComponentInputMap inputMap) {
InputMap km = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
*** 2223,2233 ****
this);
}
/**
* This method is now obsolete, please use a combination of
! * <code>getActionMap()</code> and <code>getInputMap()</code> for
* similar behavior.
*
* @param anAction action to be registered to given keystroke and condition
* @param aKeyStroke a {@code KeyStroke}
* @param aCondition the condition to be associated with given keystroke
--- 2223,2233 ----
this);
}
/**
* This method is now obsolete, please use a combination of
! * {@code getActionMap()} and {@code getInputMap()} for
* similar behavior.
*
* @param anAction action to be registered to given keystroke and condition
* @param aKeyStroke a {@code KeyStroke}
* @param aCondition the condition to be associated with given keystroke
*** 2240,2259 ****
}
/**
* This method is now obsolete. To unregister an existing binding
* you can either remove the binding from the
! * <code>ActionMap/InputMap</code>, or place a dummy binding the
! * <code>InputMap</code>. Removing the binding from the
! * <code>InputMap</code> allows bindings in parent <code>InputMap</code>s
* to be active, whereas putting a dummy binding in the
! * <code>InputMap</code> effectively disables
* the binding from ever happening.
* <p>
* Unregisters a keyboard action.
! * This will remove the binding from the <code>ActionMap</code>
! * (if it exists) as well as the <code>InputMap</code>s.
*
* @param aKeyStroke the keystroke for which to unregister its
* keyboard action
*/
public void unregisterKeyboardAction(KeyStroke aKeyStroke) {
--- 2240,2259 ----
}
/**
* This method is now obsolete. To unregister an existing binding
* you can either remove the binding from the
! * {@code ActionMap/InputMap}, or place a dummy binding the
! * {@code InputMap}. Removing the binding from the
! * {@code InputMap} allows bindings in parent {@code InputMap}s
* to be active, whereas putting a dummy binding in the
! * {@code InputMap} effectively disables
* the binding from ever happening.
* <p>
* Unregisters a keyboard action.
! * This will remove the binding from the {@code ActionMap}
! * (if it exists) as well as the {@code InputMap}s.
*
* @param aKeyStroke the keystroke for which to unregister its
* keyboard action
*/
public void unregisterKeyboardAction(KeyStroke aKeyStroke) {
*** 2270,2283 ****
}
}
}
/**
! * Returns the <code>KeyStrokes</code> that will initiate
* registered actions.
*
! * @return an array of <code>KeyStroke</code> objects
* @see #registerKeyboardAction
*/
public KeyStroke[] getRegisteredKeyStrokes() {
int[] counts = new int[3];
KeyStroke[][] strokes = new KeyStroke[3][];
--- 2270,2283 ----
}
}
}
/**
! * Returns the {@code KeyStrokes} that will initiate
* registered actions.
*
! * @return an array of {@code KeyStroke} objects
* @see #registerKeyboardAction
*/
public KeyStroke[] getRegisteredKeyStrokes() {
int[] counts = new int[3];
KeyStroke[][] strokes = new KeyStroke[3][];
*** 2302,2316 ****
/**
* Returns the condition that determines whether a registered action
* occurs in response to the specified keystroke.
* <p>
! * For Java 2 platform v1.3, a <code>KeyStroke</code> can be associated
* with more than one condition.
* For example, 'a' could be bound for the two
! * conditions <code>WHEN_FOCUSED</code> and
! * <code>WHEN_IN_FOCUSED_WINDOW</code> condition.
*
* @param aKeyStroke the keystroke for which to request an
* action-keystroke condition
* @return the action-keystroke condition
*/
--- 2302,2316 ----
/**
* Returns the condition that determines whether a registered action
* occurs in response to the specified keystroke.
* <p>
! * For Java 2 platform v1.3, a {@code KeyStroke} can be associated
* with more than one condition.
* For example, 'a' could be bound for the two
! * conditions {@code WHEN_FOCUSED} and
! * {@code WHEN_IN_FOCUSED_WINDOW} condition.
*
* @param aKeyStroke the keystroke for which to request an
* action-keystroke condition
* @return the action-keystroke condition
*/
*** 2327,2337 ****
/**
* Returns the object that will perform the action registered for a
* given keystroke.
*
* @param aKeyStroke the keystroke for which to return a listener
! * @return the <code>ActionListener</code>
* object invoked when the keystroke occurs
*/
public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke) {
ActionMap am = getActionMap(false);
--- 2327,2337 ----
/**
* Returns the object that will perform the action registered for a
* given keystroke.
*
* @param aKeyStroke the keystroke for which to return a listener
! * @return the {@code ActionListener}
* object invoked when the keystroke occurs
*/
public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke) {
ActionMap am = getActionMap(false);
*** 2354,2367 ****
}
return null;
}
/**
! * Unregisters all the bindings in the first tier <code>InputMaps</code>
! * and <code>ActionMap</code>. This has the effect of removing any
* local bindings, and allowing the bindings defined in parent
! * <code>InputMap/ActionMaps</code>
* (the UI is usually defined in the second tier) to persist.
*/
public void resetKeyboardActions() {
// Keys
for (int counter = 0; counter < 3; counter++) {
--- 2354,2367 ----
}
return null;
}
/**
! * Unregisters all the bindings in the first tier {@code InputMaps}
! * and {@code ActionMap}. This has the effect of removing any
* local bindings, and allowing the bindings defined in parent
! * {@code InputMap/ActionMaps}
* (the UI is usually defined in the second tier) to persist.
*/
public void resetKeyboardActions() {
// Keys
for (int counter = 0; counter < 3; counter++) {
*** 2379,2411 ****
am.clear();
}
}
/**
! * Sets the <code>InputMap</code> to use under the condition
! * <code>condition</code> to
! * <code>map</code>. A <code>null</code> value implies you
* do not want any bindings to be used, even from the UI. This will
! * not reinstall the UI <code>InputMap</code> (if there was one).
! * <code>condition</code> has one of the following values:
* <ul>
! * <li><code>WHEN_IN_FOCUSED_WINDOW</code>
! * <li><code>WHEN_FOCUSED</code>
! * <li><code>WHEN_ANCESTOR_OF_FOCUSED_COMPONENT</code>
* </ul>
! * If <code>condition</code> is <code>WHEN_IN_FOCUSED_WINDOW</code>
! * and <code>map</code> is not a <code>ComponentInputMap</code>, an
! * <code>IllegalArgumentException</code> will be thrown.
! * Similarly, if <code>condition</code> is not one of the values
! * listed, an <code>IllegalArgumentException</code> will be thrown.
*
* @param condition one of the values listed above
! * @param map the <code>InputMap</code> to use for the given condition
! * @exception IllegalArgumentException if <code>condition</code> is
! * <code>WHEN_IN_FOCUSED_WINDOW</code> and <code>map</code>
! * is not an instance of <code>ComponentInputMap</code>; or
! * if <code>condition</code> is not one of the legal values
* specified above
* @since 1.3
*/
public final void setInputMap(int condition, InputMap map) {
switch (condition) {
--- 2379,2411 ----
am.clear();
}
}
/**
! * Sets the {@code InputMap} to use under the condition
! * {@code condition} to
! * {@code map}. A {@code null} value implies you
* do not want any bindings to be used, even from the UI. This will
! * not reinstall the UI {@code InputMap} (if there was one).
! * {@code condition} has one of the following values:
* <ul>
! * <li>{@code WHEN_IN_FOCUSED_WINDOW}
! * <li>{@code WHEN_FOCUSED}
! * <li>{@code WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}
* </ul>
! * If {@code condition} is {@code WHEN_IN_FOCUSED_WINDOW}
! * and {@code map} is not a {@code ComponentInputMap}, an
! * {@code IllegalArgumentException} will be thrown.
! * Similarly, if {@code condition} is not one of the values
! * listed, an {@code IllegalArgumentException} will be thrown.
*
* @param condition one of the values listed above
! * @param map the {@code InputMap} to use for the given condition
! * @exception IllegalArgumentException if {@code condition} is
! * {@code WHEN_IN_FOCUSED_WINDOW} and {@code map}
! * is not an instance of {@code ComponentInputMap}; or
! * if {@code condition} is not one of the legal values
* specified above
* @since 1.3
*/
public final void setInputMap(int condition, InputMap map) {
switch (condition) {
*** 2429,2507 ****
throw new IllegalArgumentException("condition must be one of JComponent.WHEN_IN_FOCUSED_WINDOW, JComponent.WHEN_FOCUSED or JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT");
}
}
/**
! * Returns the <code>InputMap</code> that is used during
! * <code>condition</code>.
*
* @param condition one of WHEN_IN_FOCUSED_WINDOW, WHEN_FOCUSED,
* WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
! * @return the <code>InputMap</code> for the specified
! * <code>condition</code>
* @since 1.3
*/
public final InputMap getInputMap(int condition) {
return getInputMap(condition, true);
}
/**
! * Returns the <code>InputMap</code> that is used when the
* component has focus.
! * This is convenience method for <code>getInputMap(WHEN_FOCUSED)</code>.
*
! * @return the <code>InputMap</code> used when the component has focus
* @since 1.3
*/
public final InputMap getInputMap() {
return getInputMap(WHEN_FOCUSED, true);
}
/**
! * Sets the <code>ActionMap</code> to <code>am</code>. This does not set
! * the parent of the <code>am</code> to be the <code>ActionMap</code>
* from the UI (if there was one), it is up to the caller to have done this.
*
! * @param am the new <code>ActionMap</code>
* @since 1.3
*/
public final void setActionMap(ActionMap am) {
actionMap = am;
setFlag(ACTIONMAP_CREATED, true);
}
/**
! * Returns the <code>ActionMap</code> used to determine what
! * <code>Action</code> to fire for particular <code>KeyStroke</code>
! * binding. The returned <code>ActionMap</code>, unless otherwise
! * set, will have the <code>ActionMap</code> from the UI set as the parent.
*
! * @return the <code>ActionMap</code> containing the key/action bindings
* @since 1.3
*/
public final ActionMap getActionMap() {
return getActionMap(true);
}
/**
! * Returns the <code>InputMap</code> to use for condition
! * <code>condition</code>. If the <code>InputMap</code> hasn't
! * been created, and <code>create</code> is
* true, it will be created.
*
* @param condition one of the following values:
* <ul>
* <li>JComponent.FOCUS_INPUTMAP_CREATED
* <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
* <li>JComponent.WHEN_IN_FOCUSED_WINDOW
* </ul>
! * @param create if true, create the <code>InputMap</code> if it
* is not already created
! * @return the <code>InputMap</code> for the given <code>condition</code>;
! * if <code>create</code> is false and the <code>InputMap</code>
! * hasn't been created, returns <code>null</code>
! * @exception IllegalArgumentException if <code>condition</code>
* is not one of the legal values listed above
*/
final InputMap getInputMap(int condition, boolean create) {
switch (condition) {
case WHEN_FOCUSED:
--- 2429,2507 ----
throw new IllegalArgumentException("condition must be one of JComponent.WHEN_IN_FOCUSED_WINDOW, JComponent.WHEN_FOCUSED or JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT");
}
}
/**
! * Returns the {@code InputMap} that is used during
! * {@code condition}.
*
* @param condition one of WHEN_IN_FOCUSED_WINDOW, WHEN_FOCUSED,
* WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
! * @return the {@code InputMap} for the specified
! * {@code condition}
* @since 1.3
*/
public final InputMap getInputMap(int condition) {
return getInputMap(condition, true);
}
/**
! * Returns the {@code InputMap} that is used when the
* component has focus.
! * This is convenience method for {@code getInputMap(WHEN_FOCUSED)}.
*
! * @return the {@code InputMap} used when the component has focus
* @since 1.3
*/
public final InputMap getInputMap() {
return getInputMap(WHEN_FOCUSED, true);
}
/**
! * Sets the {@code ActionMap} to {@code am}. This does not set
! * the parent of the {@code am} to be the {@code ActionMap}
* from the UI (if there was one), it is up to the caller to have done this.
*
! * @param am the new {@code ActionMap}
* @since 1.3
*/
public final void setActionMap(ActionMap am) {
actionMap = am;
setFlag(ACTIONMAP_CREATED, true);
}
/**
! * Returns the {@code ActionMap} used to determine what
! * {@code Action} to fire for particular {@code KeyStroke}
! * binding. The returned {@code ActionMap}, unless otherwise
! * set, will have the {@code ActionMap} from the UI set as the parent.
*
! * @return the {@code ActionMap} containing the key/action bindings
* @since 1.3
*/
public final ActionMap getActionMap() {
return getActionMap(true);
}
/**
! * Returns the {@code InputMap} to use for condition
! * {@code condition}. If the {@code InputMap} hasn't
! * been created, and {@code create} is
* true, it will be created.
*
* @param condition one of the following values:
* <ul>
* <li>JComponent.FOCUS_INPUTMAP_CREATED
* <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
* <li>JComponent.WHEN_IN_FOCUSED_WINDOW
* </ul>
! * @param create if true, create the {@code InputMap} if it
* is not already created
! * @return the {@code InputMap} for the given {@code condition};
! * if {@code create} is false and the {@code InputMap}
! * hasn't been created, returns {@code null}
! * @exception IllegalArgumentException if {@code condition}
* is not one of the legal values listed above
*/
final InputMap getInputMap(int condition, boolean create) {
switch (condition) {
case WHEN_FOCUSED:
*** 2542,2558 ****
}
return null;
}
/**
! * Finds and returns the appropriate <code>ActionMap</code>.
*
! * @param create if true, create the <code>ActionMap</code> if it
* is not already created
! * @return the <code>ActionMap</code> for this component; if the
! * <code>create</code> flag is false and there is no
! * current <code>ActionMap</code>, returns <code>null</code>
*/
final ActionMap getActionMap(boolean create) {
if (getFlag(ACTIONMAP_CREATED)) {
return actionMap;
}
--- 2542,2558 ----
}
return null;
}
/**
! * Finds and returns the appropriate {@code ActionMap}.
*
! * @param create if true, create the {@code ActionMap} if it
* is not already created
! * @return the {@code ActionMap} for this component; if the
! * {@code create} flag is false and there is no
! * current {@code ActionMap}, returns {@code null}
*/
final ActionMap getActionMap(boolean create) {
if (getFlag(ACTIONMAP_CREATED)) {
return actionMap;
}
*** 2566,2586 ****
}
/**
* Returns the baseline. The baseline is measured from the top of
* the component. This method is primarily meant for
! * <code>LayoutManager</code>s to align components along their
* baseline. A return value less than 0 indicates this component
* does not have a reasonable baseline and that
! * <code>LayoutManager</code>s should not align this component on
* its baseline.
* <p>
! * This method calls into the <code>ComponentUI</code> method of the
! * same name. If this component does not have a <code>ComponentUI</code>
* -1 will be returned. If a value >= 0 is
* returned, then the component has a valid baseline for any
! * size >= the minimum size and <code>getBaselineResizeBehavior</code>
* can be used to determine how the baseline changes with size.
*
* @throws IllegalArgumentException {@inheritDoc}
* @see #getBaselineResizeBehavior
* @see java.awt.FontMetrics
--- 2566,2586 ----
}
/**
* Returns the baseline. The baseline is measured from the top of
* the component. This method is primarily meant for
! * {@code LayoutManager}s to align components along their
* baseline. A return value less than 0 indicates this component
* does not have a reasonable baseline and that
! * {@code LayoutManager}s should not align this component on
* its baseline.
* <p>
! * This method calls into the {@code ComponentUI} method of the
! * same name. If this component does not have a {@code ComponentUI}
* -1 will be returned. If a value >= 0 is
* returned, then the component has a valid baseline for any
! * size >= the minimum size and {@code getBaselineResizeBehavior}
* can be used to determine how the baseline changes with size.
*
* @throws IllegalArgumentException {@inheritDoc}
* @see #getBaselineResizeBehavior
* @see java.awt.FontMetrics
*** 2598,2619 ****
/**
* Returns an enum indicating how the baseline of the component
* changes as the size changes. This method is primarily meant for
* layout managers and GUI builders.
* <p>
! * This method calls into the <code>ComponentUI</code> method of
* the same name. If this component does not have a
! * <code>ComponentUI</code>
! * <code>BaselineResizeBehavior.OTHER</code> will be
* returned. Subclasses should
! * never return <code>null</code>; if the baseline can not be
! * calculated return <code>BaselineResizeBehavior.OTHER</code>. Callers
* should first ask for the baseline using
! * <code>getBaseline</code> and if a value >= 0 is returned use
* this method. It is acceptable for this method to return a
! * value other than <code>BaselineResizeBehavior.OTHER</code> even if
! * <code>getBaseline</code> returns a value less than 0.
*
* @see #getBaseline(int, int)
* @since 1.6
*/
public BaselineResizeBehavior getBaselineResizeBehavior() {
--- 2598,2619 ----
/**
* Returns an enum indicating how the baseline of the component
* changes as the size changes. This method is primarily meant for
* layout managers and GUI builders.
* <p>
! * This method calls into the {@code ComponentUI} method of
* the same name. If this component does not have a
! * {@code ComponentUI}
! * {@code BaselineResizeBehavior.OTHER} will be
* returned. Subclasses should
! * never return {@code null}; if the baseline can not be
! * calculated return {@code BaselineResizeBehavior.OTHER}. Callers
* should first ask for the baseline using
! * {@code getBaseline} and if a value >= 0 is returned use
* this method. It is acceptable for this method to return a
! * value other than {@code BaselineResizeBehavior.OTHER} even if
! * {@code getBaseline} returns a value less than 0.
*
* @see #getBaseline(int, int)
* @since 1.6
*/
public BaselineResizeBehavior getBaselineResizeBehavior() {
*** 2628,2649 ****
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Requests focus on this <code>JComponent</code>'s
! * <code>FocusTraversalPolicy</code>'s default <code>Component</code>.
! * If this <code>JComponent</code> is a focus cycle root, then its
! * <code>FocusTraversalPolicy</code> is used. Otherwise, the
! * <code>FocusTraversalPolicy</code> of this <code>JComponent</code>'s
* focus-cycle-root ancestor is used.
*
* @return true if this component can request to get the input focus,
* false if it can not
* @see java.awt.FocusTraversalPolicy#getDefaultComponent
* @deprecated As of 1.4, replaced by
! * <code>FocusTraversalPolicy.getDefaultComponent(Container).requestFocus()</code>
*/
@Deprecated
public boolean requestDefaultFocus() {
Container nearestRoot =
(isFocusCycleRoot()) ? this : getFocusCycleRootAncestor();
--- 2628,2649 ----
* For more information, see
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html">
* How to Use the Focus Subsystem</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
! * Requests focus on this {@code JComponent}'s
! * {@code FocusTraversalPolicy}'s default {@code Component}.
! * If this {@code JComponent} is a focus cycle root, then its
! * {@code FocusTraversalPolicy} is used. Otherwise, the
! * {@code FocusTraversalPolicy} of this {@code JComponent}'s
* focus-cycle-root ancestor is used.
*
* @return true if this component can request to get the input focus,
* false if it can not
* @see java.awt.FocusTraversalPolicy#getDefaultComponent
* @deprecated As of 1.4, replaced by
! * {@code FocusTraversalPolicy.getDefaultComponent(Container).requestFocus()}
*/
@Deprecated
public boolean requestDefaultFocus() {
Container nearestRoot =
(isFocusCycleRoot()) ? this : getFocusCycleRootAncestor();
*** 2660,2670 ****
}
}
/**
* Makes the component visible or invisible.
! * Overrides <code>Component.setVisible</code>.
*
* @param aFlag true to make the component visible; false to
* make it invisible
*
* @beaninfo
--- 2660,2670 ----
}
}
/**
* Makes the component visible or invisible.
! * Overrides {@code Component.setVisible}.
*
* @param aFlag true to make the component visible; false to
* make it invisible
*
* @beaninfo
*** 2718,2728 ****
/**
* Sets the foreground color of this component. It is up to the
* look and feel to honor this property, some may choose to ignore
* it.
*
! * @param fg the desired foreground <code>Color</code>
* @see java.awt.Component#getForeground
*
* @beaninfo
* preferred: true
* bound: true
--- 2718,2728 ----
/**
* Sets the foreground color of this component. It is up to the
* look and feel to honor this property, some may choose to ignore
* it.
*
! * @param fg the desired foreground {@code Color}
* @see java.awt.Component#getForeground
*
* @beaninfo
* preferred: true
* bound: true
*** 2739,2757 ****
}
/**
* Sets the background color of this component. The background
* color is used only if the component is opaque, and only
! * by subclasses of <code>JComponent</code> or
! * <code>ComponentUI</code> implementations. Direct subclasses of
! * <code>JComponent</code> must override
! * <code>paintComponent</code> to honor this property.
* <p>
* It is up to the look and feel to honor this property, some may
* choose to ignore it.
*
! * @param bg the desired background <code>Color</code>
* @see java.awt.Component#getBackground
* @see #setOpaque
*
* @beaninfo
* preferred: true
--- 2739,2757 ----
}
/**
* Sets the background color of this component. The background
* color is used only if the component is opaque, and only
! * by subclasses of {@code JComponent} or
! * {@code ComponentUI} implementations. Direct subclasses of
! * {@code JComponent} must override
! * {@code paintComponent} to honor this property.
* <p>
* It is up to the look and feel to honor this property, some may
* choose to ignore it.
*
! * @param bg the desired background {@code Color}
* @see java.awt.Component#getBackground
* @see #setOpaque
*
* @beaninfo
* preferred: true
*** 2769,2779 ****
}
/**
* Sets the font for this component.
*
! * @param font the desired <code>Font</code> for this component
* @see java.awt.Component#getFont
*
* @beaninfo
* preferred: true
* bound: true
--- 2769,2779 ----
}
/**
* Sets the font for this component.
*
! * @param font the desired {@code Font} for this component
* @see java.awt.Component#getFont
*
* @beaninfo
* preferred: true
* bound: true
*** 2797,2807 ****
* The default locale has "AppContext" scope so that applets (and
* potentially multiple lightweight applications running in a single VM)
* can have their own setting. An applet can safely alter its default
* locale because it will have no affect on other applets (or the browser).
*
! * @return the default <code>Locale</code>.
* @see #setDefaultLocale
* @see java.awt.Component#getLocale
* @see #setLocale
* @since 1.4
*/
--- 2797,2807 ----
* The default locale has "AppContext" scope so that applets (and
* potentially multiple lightweight applications running in a single VM)
* can have their own setting. An applet can safely alter its default
* locale because it will have no affect on other applets (or the browser).
*
! * @return the default {@code Locale}.
* @see #setDefaultLocale
* @see java.awt.Component#getLocale
* @see #setLocale
* @since 1.4
*/
*** 2824,2834 ****
* The default locale has "AppContext" scope so that applets (and
* potentially multiple lightweight applications running in a single VM)
* can have their own setting. An applet can safely alter its default
* locale because it will have no affect on other applets (or the browser).
*
! * @param l the desired default <code>Locale</code> for new components.
* @see #getDefaultLocale
* @see java.awt.Component#getLocale
* @see #setLocale
* @since 1.4
*/
--- 2824,2834 ----
* The default locale has "AppContext" scope so that applets (and
* potentially multiple lightweight applications running in a single VM)
* can have their own setting. An applet can safely alter its default
* locale because it will have no affect on other applets (or the browser).
*
! * @param l the desired default {@code Locale} for new components.
* @see #getDefaultLocale
* @see java.awt.Component#getLocale
* @see #setLocale
* @since 1.4
*/
*** 2854,2864 ****
* @param e the event to be processed
*/
protected void processComponentKeyEvent(KeyEvent e) {
}
! /** Overrides <code>processKeyEvent</code> to process events. **/
protected void processKeyEvent(KeyEvent e) {
boolean result;
boolean shouldProcessKey;
// This gives the key event listeners a crack at the event
--- 2854,2864 ----
* @param e the event to be processed
*/
protected void processComponentKeyEvent(KeyEvent e) {
}
! /** Overrides {@code processKeyEvent} to process events. **/
protected void processKeyEvent(KeyEvent e) {
boolean result;
boolean shouldProcessKey;
// This gives the key event listeners a crack at the event
*** 2880,2898 ****
e.consume();
}
}
/**
! * Invoked to process the key bindings for <code>ks</code> as the result
! * of the <code>KeyEvent</code> <code>e</code>. This obtains
! * the appropriate <code>InputMap</code>,
! * gets the binding, gets the action from the <code>ActionMap</code>,
* and then (if the action is found and the component
! * is enabled) invokes <code>notifyAction</code> to notify the action.
*
! * @param ks the <code>KeyStroke</code> queried
! * @param e the <code>KeyEvent</code>
* @param condition one of the following values:
* <ul>
* <li>JComponent.WHEN_FOCUSED
* <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
* <li>JComponent.WHEN_IN_FOCUSED_WINDOW
--- 2880,2898 ----
e.consume();
}
}
/**
! * Invoked to process the key bindings for {@code ks} as the result
! * of the {@code KeyEvent e}. This obtains
! * the appropriate {@code InputMap},
! * gets the binding, gets the action from the {@code ActionMap},
* and then (if the action is found and the component
! * is enabled) invokes {@code notifyAction} to notify the action.
*
! * @param ks the {@code KeyStroke} queried
! * @param e the {@code KeyEvent}
* @param condition one of the following values:
* <ul>
* <li>JComponent.WHEN_FOCUSED
* <li>JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
* <li>JComponent.WHEN_IN_FOCUSED_WINDOW
*** 2918,2937 ****
}
return false;
}
/**
! * This is invoked as the result of a <code>KeyEvent</code>
! * that was not consumed by the <code>FocusManager</code>,
! * <code>KeyListeners</code>, or the component. It will first try
! * <code>WHEN_FOCUSED</code> bindings,
! * then <code>WHEN_ANCESTOR_OF_FOCUSED_COMPONENT</code> bindings,
! * and finally <code>WHEN_IN_FOCUSED_WINDOW</code> bindings.
*
! * @param e the unconsumed <code>KeyEvent</code>
* @param pressed true if the key is pressed
! * @return true if there is a key binding for <code>e</code>
*/
boolean processKeyBindings(KeyEvent e, boolean pressed) {
if (!SwingUtilities.isValidKeyEventForKeyBindings(e)) {
return false;
}
--- 2918,2937 ----
}
return false;
}
/**
! * This is invoked as the result of a {@code KeyEvent}
! * that was not consumed by the {@code FocusManager},
! * {@code KeyListeners}, or the component. It will first try
! * {@code WHEN_FOCUSED} bindings,
! * then {@code WHEN_ANCESTOR_OF_FOCUSED_COMPONENT} bindings,
! * and finally {@code WHEN_IN_FOCUSED_WINDOW} bindings.
*
! * @param e the unconsumed {@code KeyEvent}
* @param pressed true if the key is pressed
! * @return true if there is a key binding for {@code e}
*/
boolean processKeyBindings(KeyEvent e, boolean pressed) {
if (!SwingUtilities.isValidKeyEventForKeyBindings(e)) {
return false;
}
*** 3023,3033 ****
* <p>
* See <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html">How to Use Tool Tips</a>
* in <em>The Java Tutorial</em>
* for further documentation.
*
! * @param text the string to display; if the text is <code>null</code>,
* the tool tip is turned off for this component
* @see #TOOL_TIP_TEXT_KEY
* @beaninfo
* preferred: true
* description: The text to display in a tool tip.
--- 3023,3033 ----
* <p>
* See <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html">How to Use Tool Tips</a>
* in <em>The Java Tutorial</em>
* for further documentation.
*
! * @param text the string to display; if the text is {@code null},
* the tool tip is turned off for this component
* @see #TOOL_TIP_TEXT_KEY
* @beaninfo
* preferred: true
* description: The text to display in a tool tip.
*** 3045,3055 ****
}
}
/**
* Returns the tooltip string that has been set with
! * <code>setToolTipText</code>.
*
* @return the text of the tool tip
* @see #TOOL_TIP_TEXT_KEY
*/
public String getToolTipText() {
--- 3045,3055 ----
}
}
/**
* Returns the tooltip string that has been set with
! * {@code setToolTipText}.
*
* @return the text of the tool tip
* @see #TOOL_TIP_TEXT_KEY
*/
public String getToolTipText() {
*** 3058,3068 ****
/**
* Returns the string to be used as the tooltip for <i>event</i>.
* By default this returns any string set using
! * <code>setToolTipText</code>. If a component provides
* more extensive API to support differing tooltips at different locations,
* this method should be overridden.
*
* @param event the {@code MouseEvent} that initiated the
* {@code ToolTip} display
--- 3058,3068 ----
/**
* Returns the string to be used as the tooltip for <i>event</i>.
* By default this returns any string set using
! * {@code setToolTipText}. If a component provides
* more extensive API to support differing tooltips at different locations,
* this method should be overridden.
*
* @param event the {@code MouseEvent} that initiated the
* {@code ToolTip} display
*** 3072,3087 ****
return getToolTipText();
}
/**
* Returns the tooltip location in this component's coordinate system.
! * If <code>null</code> is returned, Swing will choose a location.
! * The default implementation returns <code>null</code>.
*
! * @param event the <code>MouseEvent</code> that caused the
! * <code>ToolTipManager</code> to show the tooltip
! * @return always returns <code>null</code>
*/
public Point getToolTipLocation(MouseEvent event) {
return null;
}
--- 3072,3087 ----
return getToolTipText();
}
/**
* Returns the tooltip location in this component's coordinate system.
! * If {@code null} is returned, Swing will choose a location.
! * The default implementation returns {@code null}.
*
! * @param event the {@code MouseEvent} that caused the
! * {@code ToolTipManager} to show the tooltip
! * @return always returns {@code null}
*/
public Point getToolTipLocation(MouseEvent event) {
return null;
}
*** 3101,3131 ****
return null;
}
/**
! * Returns the instance of <code>JToolTip</code> that should be used
* to display the tooltip.
* Components typically would not override this method,
* but it can be used to
* cause different tooltips to be displayed differently.
*
! * @return the <code>JToolTip</code> used to display this toolTip
*/
public JToolTip createToolTip() {
JToolTip tip = new JToolTip();
tip.setComponent(this);
return tip;
}
/**
! * Forwards the <code>scrollRectToVisible()</code> message to the
! * <code>JComponent</code>'s parent. Components that can service
! * the request, such as <code>JViewport</code>,
* override this method and perform the scrolling.
*
! * @param aRect the visible <code>Rectangle</code>
* @see JViewport
*/
public void scrollRectToVisible(Rectangle aRect) {
Container parent;
int dx = getX(), dy = getY();
--- 3101,3131 ----
return null;
}
/**
! * Returns the instance of {@code JToolTip} that should be used
* to display the tooltip.
* Components typically would not override this method,
* but it can be used to
* cause different tooltips to be displayed differently.
*
! * @return the {@code JToolTip} used to display this toolTip
*/
public JToolTip createToolTip() {
JToolTip tip = new JToolTip();
tip.setComponent(this);
return tip;
}
/**
! * Forwards the {@code scrollRectToVisible()} message to the
! * {@code JComponent}'s parent. Components that can service
! * the request, such as {@code JViewport},
* override this method and perform the scrolling.
*
! * @param aRect the visible {@code Rectangle}
* @see JViewport
*/
public void scrollRectToVisible(Rectangle aRect) {
Container parent;
int dx = getX(), dy = getY();
*** 3150,3189 ****
aRect.y -= dy;
}
}
/**
! * Sets the <code>autoscrolls</code> property.
! * If <code>true</code> mouse dragged events will be
* synthetically generated when the mouse is dragged
* outside of the component's bounds and mouse motion
* has paused (while the button continues to be held
* down). The synthetic events make it appear that the
* drag gesture has resumed in the direction established when
* the component's boundary was crossed. Components that
! * support autoscrolling must handle <code>mouseDragged</code>
! * events by calling <code>scrollRectToVisible</code> with a
* rectangle that contains the mouse event's location. All of
* the Swing components that support item selection and are
! * typically displayed in a <code>JScrollPane</code>
! * (<code>JTable</code>, <code>JList</code>, <code>JTree</code>,
! * <code>JTextArea</code>, and <code>JEditorPane</code>)
* already handle mouse dragged events in this way. To enable
* autoscrolling in any other component, add a mouse motion
! * listener that calls <code>scrollRectToVisible</code>.
! * For example, given a <code>JPanel</code>, <code>myPanel</code>:
* <pre>
* MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
* public void mouseDragged(MouseEvent e) {
* Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
* ((JPanel)e.getSource()).scrollRectToVisible(r);
* }
* };
* myPanel.addMouseMotionListener(doScrollRectToVisible);
* </pre>
! * The default value of the <code>autoScrolls</code>
! * property is <code>false</code>.
*
* @param autoscrolls if true, synthetic mouse dragged events
* are generated when the mouse is dragged outside of a component's
* bounds and the mouse button continues to be held down; otherwise
* false
--- 3150,3189 ----
aRect.y -= dy;
}
}
/**
! * Sets the {@code autoscrolls} property.
! * If {@code true} mouse dragged events will be
* synthetically generated when the mouse is dragged
* outside of the component's bounds and mouse motion
* has paused (while the button continues to be held
* down). The synthetic events make it appear that the
* drag gesture has resumed in the direction established when
* the component's boundary was crossed. Components that
! * support autoscrolling must handle {@code mouseDragged}
! * events by calling {@code scrollRectToVisible} with a
* rectangle that contains the mouse event's location. All of
* the Swing components that support item selection and are
! * typically displayed in a {@code JScrollPane}
! * ({@code JTable}, {@code JList}, {@code JTree},
! * {@code JTextArea}, and {@code JEditorPane})
* already handle mouse dragged events in this way. To enable
* autoscrolling in any other component, add a mouse motion
! * listener that calls {@code scrollRectToVisible}.
! * For example, given a {@code JPanel}, {@code myPanel}:
* <pre>
* MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
* public void mouseDragged(MouseEvent e) {
* Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
* ((JPanel)e.getSource()).scrollRectToVisible(r);
* }
* };
* myPanel.addMouseMotionListener(doScrollRectToVisible);
* </pre>
! * The default value of the {@code autoScrolls}
! * property is {@code false}.
*
* @param autoscrolls if true, synthetic mouse dragged events
* are generated when the mouse is dragged outside of a component's
* bounds and the mouse button continues to be held down; otherwise
* false
*** 3208,3220 ****
}
}
}
/**
! * Gets the <code>autoscrolls</code> property.
*
! * @return the value of the <code>autoscrolls</code> property
* @see JViewport
* @see #setAutoscrolls
*/
public boolean getAutoscrolls() {
return autoscrolls;
--- 3208,3220 ----
}
}
}
/**
! * Gets the {@code autoscrolls} property.
*
! * @return the value of the {@code autoscrolls} property
* @see JViewport
* @see #setAutoscrolls
*/
public boolean getAutoscrolls() {
return autoscrolls;
*** 3267,3279 ****
SwingUtilities.installSwingDropTargetAsNecessary(this, newHandler);
firePropertyChange("transferHandler", oldHandler, newHandler);
}
/**
! * Gets the <code>transferHandler</code> property.
*
! * @return the value of the <code>transferHandler</code> property
*
* @see TransferHandler
* @see #setTransferHandler
* @since 1.4
*/
--- 3267,3279 ----
SwingUtilities.installSwingDropTargetAsNecessary(this, newHandler);
firePropertyChange("transferHandler", oldHandler, newHandler);
}
/**
! * Gets the {@code transferHandler} property.
*
! * @return the value of the {@code transferHandler} property
*
* @see TransferHandler
* @see #setTransferHandler
* @since 1.4
*/
*** 3282,3298 ****
}
/**
* Calculates a custom drop location for this type of component,
* representing where a drop at the given point should insert data.
! * <code>null</code> is returned if this component doesn't calculate
! * custom drop locations. In this case, <code>TransferHandler</code>
! * will provide a default <code>DropLocation</code> containing just
* the point.
*
* @param p the point to calculate a drop location for
! * @return the drop location, or <code>null</code>
*/
TransferHandler.DropLocation dropLocationForPoint(Point p) {
return null;
}
--- 3282,3298 ----
}
/**
* Calculates a custom drop location for this type of component,
* representing where a drop at the given point should insert data.
! * {@code null} is returned if this component doesn't calculate
! * custom drop locations. In this case, {@code TransferHandler}
! * will provide a default {@code DropLocation} containing just
* the point.
*
* @param p the point to calculate a drop location for
! * @return the drop location, or {@code null}
*/
TransferHandler.DropLocation dropLocationForPoint(Point p) {
return null;
}
*** 3312,3354 ****
* a drop index). It can return a state object to the caller encapsulating
* any saved selection state. On a second call, let's say the drop location
* is being changed to something else. The component doesn't need to
* restore anything yet, so it simply passes back the same state object
* to have the DnD system continue storing it. Finally, let's say this
! * method is messaged with <code>null</code>. This means DnD
* is finished with this component for now, meaning it should restore
* state. At this point, it can use the state parameter to restore
! * said state, and of course return <code>null</code> since there's
* no longer anything to store.
*
* @param location the drop location (as calculated by
! * <code>dropLocationForPoint</code>) or <code>null</code>
* if there's no longer a valid drop location
* @param state the state object saved earlier for this component,
! * or <code>null</code>
* @param forDrop whether or not the method is being called because an
* actual drop occurred
! * @return any saved state for this component, or <code>null</code> if none
*/
Object setDropLocation(TransferHandler.DropLocation location,
Object state,
boolean forDrop) {
return null;
}
/**
* Called to indicate to this component that DnD is done.
! * Needed by <code>JTree</code>.
*/
void dndDone() {
}
/**
* Processes mouse events occurring on this component by
* dispatching them to any registered
! * <code>MouseListener</code> objects, refer to
* {@link java.awt.Component#processMouseEvent(MouseEvent)}
* for a complete description of this method.
*
* @param e the mouse event
* @see java.awt.Component#processMouseEvent
--- 3312,3354 ----
* a drop index). It can return a state object to the caller encapsulating
* any saved selection state. On a second call, let's say the drop location
* is being changed to something else. The component doesn't need to
* restore anything yet, so it simply passes back the same state object
* to have the DnD system continue storing it. Finally, let's say this
! * method is messaged with {@code null}. This means DnD
* is finished with this component for now, meaning it should restore
* state. At this point, it can use the state parameter to restore
! * said state, and of course return {@code null} since there's
* no longer anything to store.
*
* @param location the drop location (as calculated by
! * {@code dropLocationForPoint}) or {@code null}
* if there's no longer a valid drop location
* @param state the state object saved earlier for this component,
! * or {@code null}
* @param forDrop whether or not the method is being called because an
* actual drop occurred
! * @return any saved state for this component, or {@code null} if none
*/
Object setDropLocation(TransferHandler.DropLocation location,
Object state,
boolean forDrop) {
return null;
}
/**
* Called to indicate to this component that DnD is done.
! * Needed by {@code JTree}.
*/
void dndDone() {
}
/**
* Processes mouse events occurring on this component by
* dispatching them to any registered
! * {@code MouseListener} objects, refer to
* {@link java.awt.Component#processMouseEvent(MouseEvent)}
* for a complete description of this method.
*
* @param e the mouse event
* @see java.awt.Component#processMouseEvent
*** 3362,3372 ****
}
/**
* Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.
*
! * @param e the <code>MouseEvent</code>
* @see MouseEvent
*/
protected void processMouseMotionEvent(MouseEvent e) {
boolean dispatch = true;
if (autoscrolls && e.getID() == MouseEvent.MOUSE_DRAGGED) {
--- 3362,3372 ----
}
/**
* Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.
*
! * @param e the {@code MouseEvent}
* @see MouseEvent
*/
protected void processMouseMotionEvent(MouseEvent e) {
boolean dispatch = true;
if (autoscrolls && e.getID() == MouseEvent.MOUSE_DRAGGED) {
*** 3384,3416 ****
void superProcessMouseMotionEvent(MouseEvent e) {
super.processMouseMotionEvent(e);
}
/**
! * This is invoked by the <code>RepaintManager</code> if
! * <code>createImage</code> is called on the component.
*
* @param newValue true if the double buffer image was created from this component
*/
void setCreatedDoubleBuffer(boolean newValue) {
setFlag(CREATED_DOUBLE_BUFFER, newValue);
}
/**
! * Returns true if the <code>RepaintManager</code>
* created the double buffer image from the component.
*
* @return true if this component had a double buffer image, false otherwise
*/
boolean getCreatedDoubleBuffer() {
return getFlag(CREATED_DOUBLE_BUFFER);
}
/**
! * <code>ActionStandin</code> is used as a standin for
! * <code>ActionListeners</code> that are
! * added via <code>registerKeyboardAction</code>.
*/
final class ActionStandin implements Action {
private final ActionListener actionListener;
private final String command;
// This will be non-null if actionListener is an Action.
--- 3384,3416 ----
void superProcessMouseMotionEvent(MouseEvent e) {
super.processMouseMotionEvent(e);
}
/**
! * This is invoked by the {@code RepaintManager} if
! * {@code createImage} is called on the component.
*
* @param newValue true if the double buffer image was created from this component
*/
void setCreatedDoubleBuffer(boolean newValue) {
setFlag(CREATED_DOUBLE_BUFFER, newValue);
}
/**
! * Returns true if the {@code RepaintManager}
* created the double buffer image from the component.
*
* @return true if this component had a double buffer image, false otherwise
*/
boolean getCreatedDoubleBuffer() {
return getFlag(CREATED_DOUBLE_BUFFER);
}
/**
! * {@code ActionStandin} is used as a standin for
! * {@code ActionListeners} that are
! * added via {@code registerKeyboardAction}.
*/
final class ActionStandin implements Action {
private final ActionListener actionListener;
private final String command;
// This will be non-null if actionListener is an Action.
*** 3650,3660 ****
* --- Accessibility Support ---
*/
/**
* @deprecated As of JDK version 1.1,
! * replaced by <code>java.awt.Component.setEnabled(boolean)</code>.
*/
@Deprecated
public void enable() {
if (isEnabled() != true) {
super.enable();
--- 3650,3660 ----
* --- Accessibility Support ---
*/
/**
* @deprecated As of JDK version 1.1,
! * replaced by {@code java.awt.Component.setEnabled(boolean)}.
*/
@Deprecated
public void enable() {
if (isEnabled() != true) {
super.enable();
*** 3666,3676 ****
}
}
/**
* @deprecated As of JDK version 1.1,
! * replaced by <code>java.awt.Component.setEnabled(boolean)</code>.
*/
@Deprecated
public void disable() {
if (isEnabled() != false) {
super.disable();
--- 3666,3676 ----
}
}
/**
* @deprecated As of JDK version 1.1,
! * replaced by {@code java.awt.Component.setEnabled(boolean)}.
*/
@Deprecated
public void disable() {
if (isEnabled() != false) {
super.disable();
*** 3692,3702 ****
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial") // Same-version serialization only
public abstract class AccessibleJComponent extends AccessibleAWTContainer
implements AccessibleExtendedComponent
--- 3692,3702 ----
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial") // Same-version serialization only
public abstract class AccessibleJComponent extends AccessibleAWTContainer
implements AccessibleExtendedComponent
*** 4031,4043 ****
}
} // inner class AccessibleJComponent
/**
! * Returns an <code>ArrayTable</code> used for
* key/value "client properties" for this component. If the
! * <code>clientProperties</code> table doesn't exist, an empty one
* will be created.
*
* @return an ArrayTable
* @see #putClientProperty
* @see #getClientProperty
--- 4031,4043 ----
}
} // inner class AccessibleJComponent
/**
! * Returns an {@code ArrayTable} used for
* key/value "client properties" for this component. If the
! * {@code clientProperties} table doesn't exist, an empty one
* will be created.
*
* @return an ArrayTable
* @see #putClientProperty
* @see #getClientProperty
*** 4050,4064 ****
}
/**
* Returns the value of the property with the specified key. Only
! * properties added with <code>putClientProperty</code> will return
! * a non-<code>null</code> value.
*
* @param key the being queried
! * @return the value of this property or <code>null</code>
* @see #putClientProperty
*/
public final Object getClientProperty(Object key) {
if (key == RenderingHints.KEY_TEXT_ANTIALIASING) {
return aaHint;
--- 4050,4064 ----
}
/**
* Returns the value of the property with the specified key. Only
! * properties added with {@code putClientProperty} will return
! * a non-{@code null} value.
*
* @param key the being queried
! * @return the value of this property or {@code null}
* @see #putClientProperty
*/
public final Object getClientProperty(Object key) {
if (key == RenderingHints.KEY_TEXT_ANTIALIASING) {
return aaHint;
*** 4075,4105 ****
}
/**
* Adds an arbitrary key/value "client property" to this component.
* <p>
! * The <code>get/putClientProperty</code> methods provide access to
* a small per-instance hashtable. Callers can use get/putClientProperty
* to annotate components that were created by another module.
* For example, a
* layout manager might store per child constraints this way. For example:
* <pre>
* componentA.putClientProperty("to the left of", componentB);
* </pre>
! * If value is <code>null</code> this method will remove the property.
* Changes to client properties are reported with
! * <code>PropertyChange</code> events.
* The name of the property (for the sake of PropertyChange
! * events) is <code>key.toString()</code>.
* <p>
! * The <code>clientProperty</code> dictionary is not intended to
* support large
* scale extensions to JComponent nor should be it considered an
* alternative to subclassing when designing a new component.
*
* @param key the new client property key
! * @param value the new client property value; if <code>null</code>
* this method will remove the property
* @see #getClientProperty
* @see #addPropertyChangeListener
*/
public final void putClientProperty(Object key, Object value) {
--- 4075,4105 ----
}
/**
* Adds an arbitrary key/value "client property" to this component.
* <p>
! * The {@code get/putClientProperty} methods provide access to
* a small per-instance hashtable. Callers can use get/putClientProperty
* to annotate components that were created by another module.
* For example, a
* layout manager might store per child constraints this way. For example:
* <pre>
* componentA.putClientProperty("to the left of", componentB);
* </pre>
! * If value is {@code null} this method will remove the property.
* Changes to client properties are reported with
! * {@code PropertyChange} events.
* The name of the property (for the sake of PropertyChange
! * events) is {@code key.toString()}.
* <p>
! * The {@code clientProperty} dictionary is not intended to
* support large
* scale extensions to JComponent nor should be it considered an
* alternative to subclassing when designing a new component.
*
* @param key the new client property key
! * @param value the new client property value; if {@code null}
* this method will remove the property
* @see #getClientProperty
* @see #addPropertyChangeListener
*/
public final void putClientProperty(Object key, Object value) {
*** 4241,4251 ****
}
/**
* @deprecated As of JDK 5,
! * replaced by <code>Component.setBounds(int, int, int, int)</code>.
* <p>
* Moves and resizes this component.
*
* @param x the new horizontal location
* @param y the new vertical location
--- 4241,4251 ----
}
/**
* @deprecated As of JDK 5,
! * replaced by {@code Component.setBounds(int, int, int, int)}.
* <p>
* Moves and resizes this component.
*
* @param x the new horizontal location
* @param y the new vertical location
*** 4259,4277 ****
}
/**
* Stores the bounds of this component into "return value"
! * <code>rv</code> and returns <code>rv</code>.
! * If <code>rv</code> is <code>null</code> a new <code>Rectangle</code>
! * is allocated. This version of <code>getBounds</code> is useful
! * if the caller wants to avoid allocating a new <code>Rectangle</code>
* object on the heap.
*
* @param rv the return value, modified to the component's bounds
! * @return <code>rv</code>; if <code>rv</code> is <code>null</code>
! * return a newly created <code>Rectangle</code> with this
* component's bounds
*/
public Rectangle getBounds(Rectangle rv) {
if (rv == null) {
return new Rectangle(getX(), getY(), getWidth(), getHeight());
--- 4259,4277 ----
}
/**
* Stores the bounds of this component into "return value"
! * {@code rv} and returns {@code rv}.
! * If {@code rv} is {@code null} a new {@code Rectangle}
! * is allocated. This version of {@code getBounds} is useful
! * if the caller wants to avoid allocating a new {@code Rectangle}
* object on the heap.
*
* @param rv the return value, modified to the component's bounds
! * @return {@code rv}; if {@code rv} is {@code null}
! * return a newly created {@code Rectangle} with this
* component's bounds
*/
public Rectangle getBounds(Rectangle rv) {
if (rv == null) {
return new Rectangle(getX(), getY(), getWidth(), getHeight());
*** 4283,4300 ****
}
/**
* Stores the width/height of this component into "return value"
! * <code>rv</code> and returns <code>rv</code>.
! * If <code>rv</code> is <code>null</code> a new <code>Dimension</code>
! * object is allocated. This version of <code>getSize</code>
* is useful if the caller wants to avoid allocating a new
! * <code>Dimension</code> object on the heap.
*
* @param rv the return value, modified to the component's size
! * @return <code>rv</code>
*/
public Dimension getSize(Dimension rv) {
if (rv == null) {
return new Dimension(getWidth(), getHeight());
}
--- 4283,4300 ----
}
/**
* Stores the width/height of this component into "return value"
! * {@code rv} and returns {@code rv}.
! * If {@code rv} is {@code null} a new {@code Dimension}
! * object is allocated. This version of {@code getSize}
* is useful if the caller wants to avoid allocating a new
! * {@code Dimension} object on the heap.
*
* @param rv the return value, modified to the component's size
! * @return {@code rv}
*/
public Dimension getSize(Dimension rv) {
if (rv == null) {
return new Dimension(getWidth(), getHeight());
}
*** 4305,4322 ****
}
/**
* Stores the x,y origin of this component into "return value"
! * <code>rv</code> and returns <code>rv</code>.
! * If <code>rv</code> is <code>null</code> a new <code>Point</code>
! * is allocated. This version of <code>getLocation</code> is useful
! * if the caller wants to avoid allocating a new <code>Point</code>
* object on the heap.
*
* @param rv the return value, modified to the component's location
! * @return <code>rv</code>
*/
public Point getLocation(Point rv) {
if (rv == null) {
return new Point(getX(), getY());
}
--- 4305,4322 ----
}
/**
* Stores the x,y origin of this component into "return value"
! * {@code rv} and returns {@code rv}.
! * If {@code rv} is {@code null} a new {@code Point}
! * is allocated. This version of {@code getLocation} is useful
! * if the caller wants to avoid allocating a new {@code Point}
* object on the heap.
*
* @param rv the return value, modified to the component's location
! * @return {@code rv}
*/
public Point getLocation(Point rv) {
if (rv == null) {
return new Point(getX(), getY());
}
*** 4328,4375 ****
/**
* Returns the current x coordinate of the component's origin.
* This method is preferable to writing
! * <code>component.getBounds().x</code>, or
! * <code>component.getLocation().x</code> because it doesn't cause any
* heap allocations.
*
* @return the current x coordinate of the component's origin
*/
public int getX() { return super.getX(); }
/**
* Returns the current y coordinate of the component's origin.
* This method is preferable to writing
! * <code>component.getBounds().y</code>, or
! * <code>component.getLocation().y</code> because it doesn't cause any
* heap allocations.
*
* @return the current y coordinate of the component's origin
*/
public int getY() { return super.getY(); }
/**
* Returns the current width of this component.
* This method is preferable to writing
! * <code>component.getBounds().width</code>, or
! * <code>component.getSize().width</code> because it doesn't cause any
* heap allocations.
*
* @return the current width of this component
*/
public int getWidth() { return super.getWidth(); }
/**
* Returns the current height of this component.
* This method is preferable to writing
! * <code>component.getBounds().height</code>, or
! * <code>component.getSize().height</code> because it doesn't cause any
* heap allocations.
*
* @return the current height of this component
*/
public int getHeight() { return super.getHeight(); }
--- 4328,4375 ----
/**
* Returns the current x coordinate of the component's origin.
* This method is preferable to writing
! * {@code component.getBounds().x}, or
! * {@code component.getLocation().x} because it doesn't cause any
* heap allocations.
*
* @return the current x coordinate of the component's origin
*/
public int getX() { return super.getX(); }
/**
* Returns the current y coordinate of the component's origin.
* This method is preferable to writing
! * {@code component.getBounds().y}, or
! * {@code component.getLocation().y} because it doesn't cause any
* heap allocations.
*
* @return the current y coordinate of the component's origin
*/
public int getY() { return super.getY(); }
/**
* Returns the current width of this component.
* This method is preferable to writing
! * {@code component.getBounds().width}, or
! * {@code component.getSize().width} because it doesn't cause any
* heap allocations.
*
* @return the current width of this component
*/
public int getWidth() { return super.getWidth(); }
/**
* Returns the current height of this component.
* This method is preferable to writing
! * {@code component.getBounds().height}, or
! * {@code component.getSize().height} because it doesn't cause any
* heap allocations.
*
* @return the current height of this component
*/
public int getHeight() { return super.getHeight(); }
*** 4396,4409 ****
/**
* If true the component paints every pixel within its bounds.
* Otherwise, the component may not paint some or all of its
* pixels, allowing the underlying pixels to show through.
* <p>
! * The default value of this property is false for <code>JComponent</code>.
* However, the default value for this property on most standard
! * <code>JComponent</code> subclasses (such as <code>JButton</code> and
! * <code>JTree</code>) is look-and-feel dependent.
*
* @param isOpaque true if this component should be opaque
* @see #isOpaque
* @beaninfo
* bound: true
--- 4396,4409 ----
/**
* If true the component paints every pixel within its bounds.
* Otherwise, the component may not paint some or all of its
* pixels, allowing the underlying pixels to show through.
* <p>
! * The default value of this property is false for {@code JComponent}.
* However, the default value for this property on most standard
! * {@code JComponent} subclasses (such as {@code JButton} and
! * {@code JTree}) is look-and-feel dependent.
*
* @param isOpaque true if this component should be opaque
* @see #isOpaque
* @beaninfo
* bound: true
*** 4420,4431 ****
/**
* If the specified rectangle is completely obscured by any of this
* component's opaque children then returns true. Only direct children
* are considered, more distant descendants are ignored. A
! * <code>JComponent</code> is opaque if
! * <code>JComponent.isOpaque()</code> returns true, other lightweight
* components are always considered transparent, and heavyweight components
* are always considered opaque.
*
* @param x x value of specified rectangle
* @param y y value of specified rectangle
--- 4420,4431 ----
/**
* If the specified rectangle is completely obscured by any of this
* component's opaque children then returns true. Only direct children
* are considered, more distant descendants are ignored. A
! * {@code JComponent} is opaque if
! * {@code JComponent.isOpaque()} returns true, other lightweight
* components are always considered transparent, and heavyweight components
* are always considered opaque.
*
* @param x x value of specified rectangle
* @param y y value of specified rectangle
*** 4466,4484 ****
return false;
}
/**
! * Returns the <code>Component</code>'s "visible rect rectangle" - the
! * intersection of the visible rectangles for the component <code>c</code>
* and all of its ancestors. The return value is stored in
! * <code>visibleRect</code>.
*
* @param c the component
! * @param visibleRect a <code>Rectangle</code> computed as the
* intersection of all visible rectangles for the component
! * <code>c</code> and all of its ancestors -- this is the
* return value for this method
* @see #getVisibleRect
*/
static final void computeVisibleRect(Component c, Rectangle visibleRect) {
Container p = c.getParent();
--- 4466,4484 ----
return false;
}
/**
! * Returns the {@code Component}'s "visible rect rectangle" - the
! * intersection of the visible rectangles for the component {@code c}
* and all of its ancestors. The return value is stored in
! * {@code visibleRect}.
*
* @param c the component
! * @param visibleRect a {@code Rectangle} computed as the
* intersection of all visible rectangles for the component
! * {@code c} and all of its ancestors -- this is the
* return value for this method
* @see #getVisibleRect
*/
static final void computeVisibleRect(Component c, Rectangle visibleRect) {
Container p = c.getParent();
*** 4494,4509 ****
}
}
/**
! * Returns the <code>Component</code>'s "visible rect rectangle" - the
* intersection of the visible rectangles for this component
* and all of its ancestors. The return value is stored in
! * <code>visibleRect</code>.
*
! * @param visibleRect a <code>Rectangle</code> computed as the
* intersection of all visible rectangles for this
* component and all of its ancestors -- this is the return
* value for this method
* @see #getVisibleRect
*/
--- 4494,4509 ----
}
}
/**
! * Returns the {@code Component}'s "visible rect rectangle" - the
* intersection of the visible rectangles for this component
* and all of its ancestors. The return value is stored in
! * {@code visibleRect}.
*
! * @param visibleRect a {@code Rectangle} computed as the
* intersection of all visible rectangles for this
* component and all of its ancestors -- this is the return
* value for this method
* @see #getVisibleRect
*/
*** 4511,4523 ****
computeVisibleRect(this, visibleRect);
}
/**
! * Returns the <code>Component</code>'s "visible rectangle" - the
* intersection of this component's visible rectangle,
! * <code>new Rectangle(0, 0, getWidth(), getHeight())</code>,
* and all of its ancestors' visible rectangles.
*
* @return the visible rectangle
*/
public Rectangle getVisibleRect() {
--- 4511,4523 ----
computeVisibleRect(this, visibleRect);
}
/**
! * Returns the {@code Component}'s "visible rectangle" - the
* intersection of this component's visible rectangle,
! * {@code new Rectangle(0, 0, getWidth(), getHeight())},
* and all of its ancestors' visible rectangles.
*
* @return the visible rectangle
*/
public Rectangle getVisibleRect() {
*** 4565,4576 ****
}
/**
* Supports reporting constrained property changes.
* This method can be called when a constrained property has changed
! * and it will send the appropriate <code>PropertyChangeEvent</code>
! * to any registered <code>VetoableChangeListeners</code>.
*
* @param propertyName the name of the property that was listened on
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @exception java.beans.PropertyVetoException when the attempt to set the
--- 4565,4576 ----
}
/**
* Supports reporting constrained property changes.
* This method can be called when a constrained property has changed
! * and it will send the appropriate {@code PropertyChangeEvent}
! * to any registered {@code VetoableChangeListeners}.
*
* @param propertyName the name of the property that was listened on
* @param oldValue the old value of the property
* @param newValue the new value of the property
* @exception java.beans.PropertyVetoException when the attempt to set the
*** 4585,4613 ****
vetoableChangeSupport.fireVetoableChange(propertyName, oldValue, newValue);
}
/**
! * Adds a <code>VetoableChangeListener</code> to the listener list.
* The listener is registered for all properties.
*
! * @param listener the <code>VetoableChangeListener</code> to be added
*/
public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {
if (vetoableChangeSupport == null) {
vetoableChangeSupport = new java.beans.VetoableChangeSupport(this);
}
vetoableChangeSupport.addVetoableChangeListener(listener);
}
/**
! * Removes a <code>VetoableChangeListener</code> from the listener list.
! * This removes a <code>VetoableChangeListener</code> that was registered
* for all properties.
*
! * @param listener the <code>VetoableChangeListener</code> to be removed
*/
public synchronized void removeVetoableChangeListener(VetoableChangeListener listener) {
if (vetoableChangeSupport == null) {
return;
}
--- 4585,4613 ----
vetoableChangeSupport.fireVetoableChange(propertyName, oldValue, newValue);
}
/**
! * Adds a {@code VetoableChangeListener} to the listener list.
* The listener is registered for all properties.
*
! * @param listener the {@code VetoableChangeListener} to be added
*/
public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {
if (vetoableChangeSupport == null) {
vetoableChangeSupport = new java.beans.VetoableChangeSupport(this);
}
vetoableChangeSupport.addVetoableChangeListener(listener);
}
/**
! * Removes a {@code VetoableChangeListener} from the listener list.
! * This removes a {@code VetoableChangeListener} that was registered
* for all properties.
*
! * @param listener the {@code VetoableChangeListener} to be removed
*/
public synchronized void removeVetoableChangeListener(VetoableChangeListener listener) {
if (vetoableChangeSupport == null) {
return;
}
*** 4617,4627 ****
/**
* Returns an array of all the vetoable change listeners
* registered on this component.
*
! * @return all of the component's <code>VetoableChangeListener</code>s
* or an empty
* array if no vetoable change listeners are currently registered
*
* @see #addVetoableChangeListener
* @see #removeVetoableChangeListener
--- 4617,4627 ----
/**
* Returns an array of all the vetoable change listeners
* registered on this component.
*
! * @return all of the component's {@code VetoableChangeListener}s
* or an empty
* array if no vetoable change listeners are currently registered
*
* @see #addVetoableChangeListener
* @see #removeVetoableChangeListener
*** 4636,4651 ****
}
/**
* Returns the top-level ancestor of this component (either the
! * containing <code>Window</code> or <code>Applet</code>),
! * or <code>null</code> if this component has not
* been added to any container.
*
! * @return the top-level <code>Container</code> that this component is in,
! * or <code>null</code> if not in any container
*/
public Container getTopLevelAncestor() {
for(Container p = this; p != null; p = p.getParent()) {
if(p instanceof Window || p instanceof Applet) {
return p;
--- 4636,4651 ----
}
/**
* Returns the top-level ancestor of this component (either the
! * containing {@code Window} or {@code Applet}),
! * or {@code null} if this component has not
* been added to any container.
*
! * @return the top-level {@code Container} that this component is in,
! * or {@code null} if not in any container
*/
public Container getTopLevelAncestor() {
for(Container p = this; p != null; p = p.getParent()) {
if(p instanceof Window || p instanceof Applet) {
return p;
*** 4658,4674 ****
return (AncestorNotifier)
getClientProperty(JComponent_ANCESTOR_NOTIFIER);
}
/**
! * Registers <code>listener</code> so that it will receive
! * <code>AncestorEvents</code> when it or any of its ancestors
* move or are made visible or invisible.
* Events are also sent when the component or its ancestors are added
* or removed from the containment hierarchy.
*
! * @param listener the <code>AncestorListener</code> to register
* @see AncestorEvent
*/
public void addAncestorListener(AncestorListener listener) {
AncestorNotifier ancestorNotifier = getAncestorNotifier();
if (ancestorNotifier == null) {
--- 4658,4674 ----
return (AncestorNotifier)
getClientProperty(JComponent_ANCESTOR_NOTIFIER);
}
/**
! * Registers {@code listener} so that it will receive
! * {@code AncestorEvents} when it or any of its ancestors
* move or are made visible or invisible.
* Events are also sent when the component or its ancestors are added
* or removed from the containment hierarchy.
*
! * @param listener the {@code AncestorListener} to register
* @see AncestorEvent
*/
public void addAncestorListener(AncestorListener listener) {
AncestorNotifier ancestorNotifier = getAncestorNotifier();
if (ancestorNotifier == null) {
*** 4678,4691 ****
}
ancestorNotifier.addAncestorListener(listener);
}
/**
! * Unregisters <code>listener</code> so that it will no longer receive
! * <code>AncestorEvents</code>.
*
! * @param listener the <code>AncestorListener</code> to be removed
* @see #addAncestorListener
*/
public void removeAncestorListener(AncestorListener listener) {
AncestorNotifier ancestorNotifier = getAncestorNotifier();
if (ancestorNotifier == null) {
--- 4678,4691 ----
}
ancestorNotifier.addAncestorListener(listener);
}
/**
! * Unregisters {@code listener} so that it will no longer receive
! * {@code AncestorEvents}.
*
! * @param listener the {@code AncestorListener} to be removed
* @see #addAncestorListener
*/
public void removeAncestorListener(AncestorListener listener) {
AncestorNotifier ancestorNotifier = getAncestorNotifier();
if (ancestorNotifier == null) {
*** 4700,4710 ****
/**
* Returns an array of all the ancestor listeners
* registered on this component.
*
! * @return all of the component's <code>AncestorListener</code>s
* or an empty
* array if no ancestor listeners are currently registered
*
* @see #addAncestorListener
* @see #removeAncestorListener
--- 4700,4710 ----
/**
* Returns an array of all the ancestor listeners
* registered on this component.
*
! * @return all of the component's {@code AncestorListener}s
* or an empty
* array if no ancestor listeners are currently registered
*
* @see #addAncestorListener
* @see #removeAncestorListener
*** 4720,4755 ****
}
/**
* Returns an array of all the objects currently registered
* as <code><em>Foo</em>Listener</code>s
! * upon this <code>JComponent</code>.
* <code><em>Foo</em>Listener</code>s are registered using the
* <code>add<em>Foo</em>Listener</code> method.
*
* <p>
*
! * You can specify the <code>listenerType</code> argument
* with a class literal,
* such as
* <code><em>Foo</em>Listener.class</code>.
* For example, you can query a
! * <code>JComponent</code> <code>c</code>
* for its mouse listeners with the following code:
* <pre>MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));</pre>
* If no such listeners exist, this method returns an empty array.
*
* @param listenerType the type of listeners requested; this parameter
* should specify an interface that descends from
! * <code>java.util.EventListener</code>
* @return an array of all objects registered as
* <code><em>Foo</em>Listener</code>s on this component,
* or an empty array if no such
* listeners have been added
! * @exception ClassCastException if <code>listenerType</code>
* doesn't specify a class or interface that implements
! * <code>java.util.EventListener</code>
*
* @since 1.3
*
* @see #getVetoableChangeListeners
* @see #getAncestorListeners
--- 4720,4755 ----
}
/**
* Returns an array of all the objects currently registered
* as <code><em>Foo</em>Listener</code>s
! * upon this {@code JComponent}.
* <code><em>Foo</em>Listener</code>s are registered using the
* <code>add<em>Foo</em>Listener</code> method.
*
* <p>
*
! * You can specify the {@code listenerType} argument
* with a class literal,
* such as
* <code><em>Foo</em>Listener.class</code>.
* For example, you can query a
! * {@code JComponent c}
* for its mouse listeners with the following code:
* <pre>MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));</pre>
* If no such listeners exist, this method returns an empty array.
*
* @param listenerType the type of listeners requested; this parameter
* should specify an interface that descends from
! * {@code java.util.EventListener}
* @return an array of all objects registered as
* <code><em>Foo</em>Listener</code>s on this component,
* or an empty array if no such
* listeners have been added
! * @exception ClassCastException if {@code listenerType}
* doesn't specify a class or interface that implements
! * {@code java.util.EventListener}
*
* @since 1.3
*
* @see #getVetoableChangeListeners
* @see #getAncestorListeners
*** 4780,4790 ****
}
/**
* Notifies this component that it now has a parent component.
* When this method is invoked, the chain of parent components is
! * set up with <code>KeyboardAction</code> event listeners.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
* @see #registerKeyboardAction
*/
--- 4780,4790 ----
}
/**
* Notifies this component that it now has a parent component.
* When this method is invoked, the chain of parent components is
! * set up with {@code KeyboardAction} event listeners.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
* @see #registerKeyboardAction
*/
*** 4797,4807 ****
}
/**
* Notifies this component that it no longer has a parent component.
! * When this method is invoked, any <code>KeyboardAction</code>s
* set up in the chain of parent components are removed.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
* @see #registerKeyboardAction
--- 4797,4807 ----
}
/**
* Notifies this component that it no longer has a parent component.
! * When this method is invoked, any {@code KeyboardAction}s
* set up in the chain of parent components are removed.
* This method is called by the toolkit internally and should
* not be called directly by programs.
*
* @see #registerKeyboardAction
*** 4849,4859 ****
/**
* Adds the specified region to the dirty region list if the component
* is showing. The component will be repainted after all of the
* currently pending events have been dispatched.
*
! * @param r a <code>Rectangle</code> containing the dirty region
* @see #isPaintingOrigin()
* @see java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
*/
public void repaint(Rectangle r) {
--- 4849,4859 ----
/**
* Adds the specified region to the dirty region list if the component
* is showing. The component will be repainted after all of the
* currently pending events have been dispatched.
*
! * @param r a {@code Rectangle} containing the dirty region
* @see #isPaintingOrigin()
* @see java.awt.Component#isShowing
* @see RepaintManager#addDirtyRegion
*/
public void repaint(Rectangle r) {
*** 4862,4886 ****
/**
* Supports deferred automatic layout.
* <p>
! * Calls <code>invalidate</code> and then adds this component's
! * <code>validateRoot</code> to a list of components that need to be
* validated. Validation will occur after all currently pending
* events have been dispatched. In other words after this method
* is called, the first validateRoot (if any) found when walking
* up the containment hierarchy of this component will be validated.
! * By default, <code>JRootPane</code>, <code>JScrollPane</code>,
! * and <code>JTextField</code> return true
! * from <code>isValidateRoot</code>.
* <p>
* This method will automatically be called on this component
* when a property value changes such that size, location, or
* internal layout of this component has been affected. This automatic
* updating differs from the AWT because programs generally no
! * longer need to invoke <code>validate</code> to get the contents of the
* GUI to update.
*
* @see java.awt.Component#invalidate
* @see java.awt.Container#validate
* @see #isValidateRoot
--- 4862,4886 ----
/**
* Supports deferred automatic layout.
* <p>
! * Calls {@code invalidate} and then adds this component's
! * {@code validateRoot} to a list of components that need to be
* validated. Validation will occur after all currently pending
* events have been dispatched. In other words after this method
* is called, the first validateRoot (if any) found when walking
* up the containment hierarchy of this component will be validated.
! * By default, {@code JRootPane}, {@code JScrollPane},
! * and {@code JTextField} return true
! * from {@code isValidateRoot}.
* <p>
* This method will automatically be called on this component
* when a property value changes such that size, location, or
* internal layout of this component has been affected. This automatic
* updating differs from the AWT because programs generally no
! * longer need to invoke {@code validate} to get the contents of the
* GUI to update.
*
* @see java.awt.Component#invalidate
* @see java.awt.Container#validate
* @see #isValidateRoot
*** 4913,4926 ****
});
}
}
/**
! * If this method returns true, <code>revalidate</code> calls by
* descendants of this component will cause the entire tree
* beginning with this root to be validated.
! * Returns false by default. <code>JScrollPane</code> overrides
* this method and returns true.
*
* @return always returns false
* @see #revalidate
* @see java.awt.Component#invalidate
--- 4913,4926 ----
});
}
}
/**
! * If this method returns true, {@code revalidate} calls by
* descendants of this component will cause the entire tree
* beginning with this root to be validated.
! * Returns false by default. {@code JScrollPane} overrides
* this method and returns true.
*
* @return always returns false
* @see #revalidate
* @see java.awt.Component#invalidate
*** 4935,4946 ****
/**
* Returns true if this component tiles its children -- that is, if
* it can guarantee that the children will not overlap. The
* repainting system is substantially more efficient in this
! * common case. <code>JComponent</code> subclasses that can't make this
! * guarantee, such as <code>JLayeredPane</code>,
* should override this method to return false.
*
* @return always returns true
*/
public boolean isOptimizedDrawingEnabled() {
--- 4935,4946 ----
/**
* Returns true if this component tiles its children -- that is, if
* it can guarantee that the children will not overlap. The
* repainting system is substantially more efficient in this
! * common case. {@code JComponent} subclasses that can't make this
! * guarantee, such as {@code JLayeredPane},
* should override this method to return false.
*
* @return always returns true
*/
public boolean isOptimizedDrawingEnabled() {
*** 5025,5043 ****
}
/**
* Paints the specified region now.
*
! * @param r a <code>Rectangle</code> containing the region to be painted
*/
public void paintImmediately(Rectangle r) {
paintImmediately(r.x,r.y,r.width,r.height);
}
/**
* Returns whether this component should be guaranteed to be on top.
! * For example, it would make no sense for <code>Menu</code>s to pop up
* under another component, so they would always return true.
* Most components will want to return false, hence that is the default.
*
* @return always returns false
*/
--- 5025,5043 ----
}
/**
* Paints the specified region now.
*
! * @param r a {@code Rectangle} containing the region to be painted
*/
public void paintImmediately(Rectangle r) {
paintImmediately(r.x,r.y,r.width,r.height);
}
/**
* Returns whether this component should be guaranteed to be on top.
! * For example, it would make no sense for {@code Menu}s to pop up
* under another component, so they would always return true.
* Most components will want to return false, hence that is the default.
*
* @return always returns false
*/
*** 5327,5337 ****
}
/**
* Returns true, which implies that before checking if a child should
* be painted it is first check that the child is not obscured by another
! * sibling. This is only checked if <code>isOptimizedDrawingEnabled</code>
* returns false.
*
* @return always returns true
*/
boolean checkIfChildObscuredBySibling() {
--- 5327,5337 ----
}
/**
* Returns true, which implies that before checking if a child should
* be painted it is first check that the child is not obscured by another
! * sibling. This is only checked if {@code isOptimizedDrawingEnabled}
* returns false.
*
* @return always returns true
*/
boolean checkIfChildObscuredBySibling() {
*** 5366,5376 ****
/**
* Sets whether this component should use a buffer to paint.
* If set to true, all the drawing from this component will be done
* in an offscreen painting buffer. The offscreen painting buffer will
* the be copied onto the screen.
! * If a <code>Component</code> is buffered and one of its ancestor
* is also buffered, the ancestor buffer will be used.
*
* @param aFlag if true, set this component to be double buffered
*/
public void setDoubleBuffered(boolean aFlag) {
--- 5366,5376 ----
/**
* Sets whether this component should use a buffer to paint.
* If set to true, all the drawing from this component will be done
* in an offscreen painting buffer. The offscreen painting buffer will
* the be copied onto the screen.
! * If a {@code Component} is buffered and one of its ancestor
* is also buffered, the ancestor buffer will be used.
*
* @param aFlag if true, set this component to be double buffered
*/
public void setDoubleBuffered(boolean aFlag) {
*** 5385,5398 ****
public boolean isDoubleBuffered() {
return getFlag(IS_DOUBLE_BUFFERED);
}
/**
! * Returns the <code>JRootPane</code> ancestor for this component.
*
! * @return the <code>JRootPane</code> that contains this component,
! * or <code>null</code> if no <code>JRootPane</code> is found
*/
public JRootPane getRootPane() {
return SwingUtilities.getRootPane(this);
}
--- 5385,5398 ----
public boolean isDoubleBuffered() {
return getFlag(IS_DOUBLE_BUFFERED);
}
/**
! * Returns the {@code JRootPane} ancestor for this component.
*
! * @return the {@code JRootPane} that contains this component,
! * or {@code null} if no {@code JRootPane} is found
*/
public JRootPane getRootPane() {
return SwingUtilities.getRootPane(this);
}
*** 5424,5443 ****
ToolTipManager.sharedInstance().unregisterComponent(JComponent.this);
}
}
/**
! * This object is the <code>ObjectInputStream</code> callback
* that's called after a complete graph of objects (including at least
! * one <code>JComponent</code>) has been read.
* It sets the UI property of each Swing component
! * that was read to the current default with <code>updateUI</code>.
* <p>
* As each component is read in we keep track of the current set of
* root components here, in the roots vector. Note that there's only one
! * <code>ReadObjectCallback</code> per <code>ObjectInputStream</code>,
! * they're stored in the static <code>readObjectCallbacks</code>
* hashtable.
*
* @see java.io.ObjectInputStream#registerValidation
* @see SwingUtilities#updateComponentTreeUI
*/
--- 5424,5443 ----
ToolTipManager.sharedInstance().unregisterComponent(JComponent.this);
}
}
/**
! * This object is the {@code ObjectInputStream} callback
* that's called after a complete graph of objects (including at least
! * one {@code JComponent}) has been read.
* It sets the UI property of each Swing component
! * that was read to the current default with {@code updateUI}.
* <p>
* As each component is read in we keep track of the current set of
* root components here, in the roots vector. Note that there's only one
! * {@code ReadObjectCallback} per {@code ObjectInputStream},
! * they're stored in the static {@code readObjectCallbacks}
* hashtable.
*
* @see java.io.ObjectInputStream#registerValidation
* @see SwingUtilities#updateComponentTreeUI
*/
*** 5453,5463 ****
/**
* This is the method that's called after the entire graph
* of objects has been read in. It initializes
* the UI property of all of the copmonents with
! * <code>SwingUtilities.updateComponentTreeUI</code>.
*/
public void validateObject() throws InvalidObjectException {
try {
for (JComponent root : roots) {
SwingUtilities.updateComponentTreeUI(root);
--- 5453,5463 ----
/**
* This is the method that's called after the entire graph
* of objects has been read in. It initializes
* the UI property of all of the copmonents with
! * {@code SwingUtilities.updateComponentTreeUI}.
*/
public void validateObject() throws InvalidObjectException {
try {
for (JComponent root : roots) {
SwingUtilities.updateComponentTreeUI(root);
*** 5467,5480 ****
readObjectCallbacks.remove(inputStream);
}
}
/**
! * If <code>c</code> isn't a descendant of a component we've already
! * seen, then add it to the roots <code>Vector</code>.
*
! * @param c the <code>JComponent</code> to add
*/
private void registerComponent(JComponent c)
{
/* If the Component c is a descendant of one of the
* existing roots (or it IS an existing root), we're done.
--- 5467,5480 ----
readObjectCallbacks.remove(inputStream);
}
}
/**
! * If {@code c} isn't a descendant of a component we've already
! * seen, then add it to the roots {@code Vector}.
*
! * @param c the {@code JComponent} to add
*/
private void registerComponent(JComponent c)
{
/* If the Component c is a descendant of one of the
* existing roots (or it IS an existing root), we're done.
*** 5505,5519 ****
}
}
/**
! * We use the <code>ObjectInputStream</code> "registerValidation"
* callback to update the UI for the entire tree of components
* after they've all been read in.
*
! * @param s the <code>ObjectInputStream</code> from which to read
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
ObjectInputStream.GetField f = s.readFields();
--- 5505,5519 ----
}
}
/**
! * We use the {@code ObjectInputStream} "registerValidation"
* callback to update the UI for the entire tree of components
* after they've all been read in.
*
! * @param s the {@code ObjectInputStream} from which to read
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
ObjectInputStream.GetField f = s.readFields();
*** 5568,5586 ****
revalidateRunnableScheduled = new AtomicBoolean(false);
}
/**
! * Before writing a <code>JComponent</code> to an
! * <code>ObjectOutputStream</code> we temporarily uninstall its UI.
* This is tricky to do because we want to uninstall
! * the UI before any of the <code>JComponent</code>'s children
! * (or its <code>LayoutManager</code> etc.) are written,
* and we don't want to restore the UI until the most derived
! * <code>JComponent</code> subclass has been stored.
*
! * @param s the <code>ObjectOutputStream</code> in which to write
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
if (getUIClassID().equals(uiClassID)) {
byte count = JComponent.getWriteObjCounter(this);
--- 5568,5586 ----
revalidateRunnableScheduled = new AtomicBoolean(false);
}
/**
! * Before writing a {@code JComponent} to an
! * {@code ObjectOutputStream} we temporarily uninstall its UI.
* This is tricky to do because we want to uninstall
! * the UI before any of the {@code JComponent}'s children
! * (or its {@code LayoutManager} etc.) are written,
* and we don't want to restore the UI until the most derived
! * {@code JComponent} subclass has been stored.
*
! * @param s the {@code ObjectOutputStream} in which to write
*/
private void writeObject(ObjectOutputStream s) throws IOException {
s.defaultWriteObject();
if (getUIClassID().equals(uiClassID)) {
byte count = JComponent.getWriteObjCounter(this);
*** 5592,5609 ****
ArrayTable.writeArrayTable(s, clientProperties);
}
/**
! * Returns a string representation of this <code>JComponent</code>.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
! * be <code>null</code>.
*
! * @return a string representation of this <code>JComponent</code>
*/
protected String paramString() {
String preferredSizeString = (isPreferredSizeSet() ?
getPreferredSize().toString() : "");
String minimumSizeString = (isMinimumSizeSet() ?
--- 5592,5609 ----
ArrayTable.writeArrayTable(s, clientProperties);
}
/**
! * Returns a string representation of this {@code JComponent}.
* This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
! * be {@code null}.
*
! * @return a string representation of this {@code JComponent}
*/
protected String paramString() {
String preferredSizeString = (isPreferredSizeSet() ?
getPreferredSize().toString() : "");
String minimumSizeString = (isMinimumSizeSet() ?
< prev index next >