aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/JComponent.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/JComponent.java')
-rw-r--r--libjava/javax/swing/JComponent.java148
1 files changed, 127 insertions, 21 deletions
diff --git a/libjava/javax/swing/JComponent.java b/libjava/javax/swing/JComponent.java
index eadf855..c22c2b2 100644
--- a/libjava/javax/swing/JComponent.java
+++ b/libjava/javax/swing/JComponent.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing;
import java.awt.AWTEvent;
@@ -68,7 +69,7 @@ import java.io.Serializable;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Locale;
-import java.util.Vector;
+
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -79,7 +80,6 @@ import javax.swing.event.EventListenerList;
import javax.swing.event.SwingPropertyChangeSupport;
import javax.swing.plaf.ComponentUI;
-
/**
* Every component in swing inherits from this class (JLabel, JButton, etc).
* It contains generic methods to manage events, properties and sizes. Actual
@@ -323,6 +323,9 @@ public abstract class JComponent extends Container implements Serializable
private InputMap inputMap_whenAncestorOfFocused;
private InputMap inputMap_whenInFocusedWindow;
private ActionMap actionMap;
+ private InputVerifier inputVerifier;
+
+ private TransferHandler transferHandler;
/**
* A lock held during recursive painting; this is used to serialize
@@ -379,6 +382,9 @@ public abstract class JComponent extends Container implements Serializable
public static final int WHEN_IN_FOCUSED_WINDOW = 2;
+ /**
+ * Creates a new <code>JComponent</code> instance.
+ */
public JComponent()
{
super();
@@ -611,8 +617,8 @@ public abstract class JComponent extends Container implements Serializable
boolean newValue)
{
if (changeSupport != null)
- changeSupport.firePropertyChange(propertyName, new Boolean(oldValue),
- new Boolean(newValue));
+ changeSupport.firePropertyChange(propertyName, Boolean.valueOf(oldValue),
+ Boolean.valueOf(newValue));
}
/**
@@ -796,13 +802,15 @@ public abstract class JComponent extends Container implements Serializable
* Set the value of the {@link #border} property, revalidate
* and repaint this component.
*
- * @param border The new value of the property
+ * @param newBorder The new value of the property
*
* @see #getBorder
*/
- public void setBorder(Border border)
+ public void setBorder(Border newBorder)
{
- this.border = border;
+ Border oldBorder = border;
+ border = newBorder;
+ firePropertyChange("border", oldBorder, newBorder);
revalidate();
repaint();
}
@@ -856,9 +864,10 @@ public abstract class JComponent extends Container implements Serializable
*/
protected Graphics getComponentGraphics(Graphics g)
{
- g.setFont(this.getFont());
- g.setColor(this.getForeground());
- return g;
+ Graphics g2 = g.create();
+ g2.setFont(this.getFont());
+ g2.setColor(this.getForeground());
+ return g2;
}
@@ -1017,12 +1026,51 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Return the value of the {@link #nextFocusableComponent} property.
+ * Checks if a maximum size was explicitely set on the component.
+ *
+ * @return <code>true</code> if a maximum size was set,
+ * <code>false</code> otherwise
*
- * @deprecated See {@link java.awt.FocusTraversalPolicy}
+ * @since 1.3
+ */
+ public boolean isMaximumSizeSet()
+ {
+ return maximumSize != null;
+ }
+
+ /**
+ * Checks if a minimum size was explicitely set on the component.
+ *
+ * @return <code>true</code> if a minimum size was set,
+ * <code>false</code> otherwise
+ *
+ * @since 1.3
+ */
+ public boolean isMinimumSizeSet()
+ {
+ return minimumSize != null;
+ }
+
+ /**
+ * Checks if a preferred size was explicitely set on the component.
+ *
+ * @return <code>true</code> if a preferred size was set,
+ * <code>false</code> otherwise
+ *
+ * @since 1.3
+ */
+ public boolean isPreferredSizeSet()
+ {
+ return preferredSize != null;
+ }
+
+ /**
+ * Return the value of the {@link #nextFocusableComponent} property.
*
* @return The current value of the property, or <code>null</code>
* if none has been set.
+ *
+ * @deprecated See {@link java.awt.FocusTraversalPolicy}
*/
public Component getNextFocusableComponent()
{
@@ -1257,7 +1305,7 @@ public abstract class JComponent extends Container implements Serializable
* @return <code>true</code> if you want this component to manage its own
* focus, otherwise (by default) <code>false</code>
*
- * @deprecated Use {@link Component.setFocusTraversalKeys(int,Set)} and
+ * @deprecated 1.4 Use {@link Component.setFocusTraversalKeys(int,Set)} and
* {@link Container.setFocusCycleRoot(boolean)} instead
*/
public boolean isManagingFocus()
@@ -1641,9 +1689,6 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * @deprecated As of 1.3 KeyStrokes can be registered with multiple
- * simultaneous conditions.
- *
* Return the condition that determines whether a registered action
* occurs in response to the specified keystroke.
*
@@ -1653,6 +1698,9 @@ public abstract class JComponent extends Container implements Serializable
* #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link
* #WHEN_IN_FOCUSED_WINDOW}
*
+ * @deprecated As of 1.3 KeyStrokes can be registered with multiple
+ * simultaneous conditions.
+ *
* @see #registerKeyboardAction
* @see #unregisterKeyboardAction
* @see #resetKeyboardActiond
@@ -1673,14 +1721,14 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * @deprecated Use {@link #getActionMap()}
- *
* Get the ActionListener (typically an {@link Action} object) which is
* associated with a particular keystroke.
*
* @param aKeyStroke The keystroke to retrieve the action of
*
* @return The action associated with the specified keystroke
+ *
+ * @deprecated Use {@link #getActionMap()}
*/
public ActionListener getActionForKeyStroke(KeyStroke ks)
{
@@ -1907,11 +1955,13 @@ public abstract class JComponent extends Container implements Serializable
* Set the value of the {@link #enabled} property, revalidate
* and repaint this component.
*
- * @param e The new value of the property
+ * @param enable The new value of the property
*/
- public void setEnabled(boolean e)
+ public void setEnabled(boolean enable)
{
- super.setEnabled(e);
+ boolean oldEnabled = isEnabled();
+ super.setEnabled(enable);
+ firePropertyChange("enabeld", oldEnabled, enable);
revalidate();
repaint();
}
@@ -1963,7 +2013,9 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setMaximumSize(Dimension max)
{
+ Dimension oldMaximumSize = maximumSize;
maximumSize = max;
+ firePropertyChange("maximumSize", oldMaximumSize, maximumSize);
revalidate();
repaint();
}
@@ -1976,7 +2028,9 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setMinimumSize(Dimension min)
{
+ Dimension oldMinimumSize = minimumSize;
minimumSize = min;
+ firePropertyChange("minimumSize", oldMinimumSize, minimumSize);
revalidate();
repaint();
}
@@ -1989,7 +2043,9 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setPreferredSize(Dimension pref)
{
+ Dimension oldPreferredSize = preferredSize;
preferredSize = pref;
+ firePropertyChange("preferredSize", oldPreferredSize, preferredSize);
}
/**
@@ -2016,6 +2072,32 @@ public abstract class JComponent extends Container implements Serializable
}
/**
+ * Get the value of the {@link #transferHandler} property.
+ *
+ * @return The current value of the property
+ *
+ * @see ComponentUI#setTransferHandler
+ */
+
+ public TransferHandler getTransferHandler()
+ {
+ return transferHandler;
+ }
+
+ /**
+ * Set the value of the {@link #transferHandler} property.
+ *
+ * @param newHandler The new value of the property
+ *
+ * @see ComponentUI#getTransferHandler
+ */
+
+ void setTransferHandler (TransferHandler newHandler)
+ {
+ transferHandler = newHandler;
+ }
+
+ /**
* Set the value of the {@link #opaque} property, revalidate and repaint
* this component.
*
@@ -2025,7 +2107,9 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setOpaque(boolean isOpaque)
{
+ boolean oldOpaque = opaque;
opaque = isOpaque;
+ firePropertyChange("opaque", oldOpaque, opaque);
revalidate();
repaint();
}
@@ -2119,4 +2203,26 @@ public abstract class JComponent extends Container implements Serializable
{
defaultLocale = l;
}
+
+ /**
+ * Returns the currently set input verifier for this component.
+ *
+ * @return the input verifier, or <code>null</code> if none
+ */
+ public InputVerifier getInputVerifier()
+ {
+ return inputVerifier;
+ }
+
+ /**
+ * Sets the input verifier to use by this component.
+ *
+ * @param verifier the input verifier, or <code>null</code>
+ */
+ public void setInputVerifier(InputVerifier verifier)
+ {
+ InputVerifier oldVerifier = inputVerifier;
+ inputVerifier = verifier;
+ firePropertyChange("inputVerifier", oldVerifier, verifier);
+ }
}