summaryrefslogtreecommitdiff
path: root/javax
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-01-16 02:14:44 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-01-16 02:14:44 +0000
commit2522f3363d0ccbb714b010c6ce79eb698052cca3 (patch)
treef9753bfb14e4195fe8c928b76e7d5407375bddf2 /javax
parent18addaa71c45fbdb60627f349e52027b3281e879 (diff)
downloadclasspath-2522f3363d0ccbb714b010c6ce79eb698052cca3.tar.gz
2005-01-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of November 2004 HEAD patches to generics branch
Diffstat (limited to 'javax')
-rw-r--r--javax/crypto/CipherInputStream.java2
-rw-r--r--javax/crypto/ExemptionMechanism.java4
-rw-r--r--javax/crypto/Mac.java4
-rw-r--r--javax/imageio/ImageIO.java5
-rw-r--r--javax/imageio/spi/ServiceRegistry.java3
-rw-r--r--javax/imageio/stream/ImageInputStreamImpl.java2
-rw-r--r--javax/naming/directory/BasicAttributes.java3
-rw-r--r--javax/net/ssl/SSLPermission.java2
-rw-r--r--javax/print/DocFlavor.java4
-rw-r--r--javax/print/attribute/AttributeSetUtilities.java23
-rw-r--r--javax/security/auth/PrivateCredentialPermission.java2
-rw-r--r--javax/swing/BorderFactory.java5
-rw-r--r--javax/swing/DefaultSingleSelectionModel.java20
-rw-r--r--javax/swing/JComponent.java35
-rw-r--r--javax/swing/JDesktopPane.java5
-rw-r--r--javax/swing/JList.java137
-rw-r--r--javax/swing/JMenuItem.java9
-rw-r--r--javax/swing/JPasswordField.java66
-rw-r--r--javax/swing/JTable.java5
-rw-r--r--javax/swing/JTree.java591
-rw-r--r--javax/swing/JViewport.java1
-rw-r--r--javax/swing/RepaintManager.java3
-rw-r--r--javax/swing/ScrollPaneLayout.java1
-rw-r--r--javax/swing/SwingUtilities.java171
-rw-r--r--javax/swing/ToolTipManager.java10
-rw-r--r--javax/swing/TransferHandler.java60
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java12
-rw-r--r--javax/swing/plaf/basic/BasicMenuItemUI.java21
-rw-r--r--javax/swing/plaf/basic/BasicTableHeaderUI.java80
-rw-r--r--javax/swing/plaf/basic/BasicTextPaneUI.java69
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java30
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java165
-rw-r--r--javax/swing/plaf/basic/BasicViewportUI.java63
-rw-r--r--javax/swing/text/FieldView.java2
-rw-r--r--javax/swing/text/GapContent.java2
-rw-r--r--javax/swing/text/JTextComponent.java13
-rw-r--r--javax/swing/text/PlainDocument.java53
-rw-r--r--javax/swing/text/SimpleAttributeSet.java3
-rw-r--r--javax/swing/text/Utilities.java12
-rw-r--r--javax/swing/tree/AbstractLayoutCache.java300
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java157
-rw-r--r--javax/swing/tree/DefaultTreeModel.java21
42 files changed, 1774 insertions, 402 deletions
diff --git a/javax/crypto/CipherInputStream.java b/javax/crypto/CipherInputStream.java
index c01cb47ac..35d495609 100644
--- a/javax/crypto/CipherInputStream.java
+++ b/javax/crypto/CipherInputStream.java
@@ -294,7 +294,7 @@ public class CipherInputStream extends FilterInputStream
*
* @param mark Is ignored.
*/
- public void mark(long mark)
+ public void mark(int mark)
{
}
diff --git a/javax/crypto/ExemptionMechanism.java b/javax/crypto/ExemptionMechanism.java
index 2b2091e15..b00ff0d5f 100644
--- a/javax/crypto/ExemptionMechanism.java
+++ b/javax/crypto/ExemptionMechanism.java
@@ -222,4 +222,8 @@ public class ExemptionMechanism
{
return true;
}
+
+ protected void finalize()
+ {
+ }
}
diff --git a/javax/crypto/Mac.java b/javax/crypto/Mac.java
index 301ec327e..9bbd68c21 100644
--- a/javax/crypto/Mac.java
+++ b/javax/crypto/Mac.java
@@ -290,7 +290,7 @@ public class Mac implements Cloneable
*
* @return The MAC length.
*/
- public int getMacLength()
+ public final int getMacLength()
{
return macSpi.engineGetMacLength();
}
@@ -404,7 +404,7 @@ public class Mac implements Cloneable
* @throws java.lang.CloneNotSupportedException If the underlying
* implementation is not cloneable.
*/
- public Object clone() throws CloneNotSupportedException
+ public final Object clone() throws CloneNotSupportedException
{
Mac result = new Mac((MacSpi) macSpi.clone(), provider, algorithm);
result.virgin = virgin;
diff --git a/javax/imageio/ImageIO.java b/javax/imageio/ImageIO.java
index 5cc7c926d..6aa555891 100644
--- a/javax/imageio/ImageIO.java
+++ b/javax/imageio/ImageIO.java
@@ -51,6 +51,11 @@ import javax.imageio.spi.ServiceRegistry;
public final class ImageIO
{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private ImageIO() {}
+
private static final class ReaderFormatFilter implements ServiceRegistry.Filter
{
private String formatName;
diff --git a/javax/imageio/spi/ServiceRegistry.java b/javax/imageio/spi/ServiceRegistry.java
index 566d50f73..3d7134ed5 100644
--- a/javax/imageio/spi/ServiceRegistry.java
+++ b/javax/imageio/spi/ServiceRegistry.java
@@ -62,6 +62,7 @@ import java.util.Set;
*/
public class ServiceRegistry
{
+ // Package-private to avoid a trampoline.
/**
* The service categories of this registry.
*
@@ -73,7 +74,7 @@ public class ServiceRegistry
*
* @see #providers
*/
- private final Class[] categories;
+ final Class[] categories;
/**
diff --git a/javax/imageio/stream/ImageInputStreamImpl.java b/javax/imageio/stream/ImageInputStreamImpl.java
index 27cb6c5b4..3a5d6dcb6 100644
--- a/javax/imageio/stream/ImageInputStreamImpl.java
+++ b/javax/imageio/stream/ImageInputStreamImpl.java
@@ -58,7 +58,7 @@ public abstract class ImageInputStreamImpl implements ImageInputStream
// Do nothing here.
}
- protected void checkClosed()
+ protected final void checkClosed()
throws IOException
{
if (closed)
diff --git a/javax/naming/directory/BasicAttributes.java b/javax/naming/directory/BasicAttributes.java
index eec1c88bb..9a9a80019 100644
--- a/javax/naming/directory/BasicAttributes.java
+++ b/javax/naming/directory/BasicAttributes.java
@@ -185,7 +185,8 @@ public class BasicAttributes implements Attributes
// This is set by the serialization spec.
private boolean ignoreCase;
- private transient Vector attributes;
+ // Package-private to avoid a trampoline.
+ transient Vector attributes;
// Used when enumerating.
private class BasicAttributesEnumeration implements NamingEnumeration
diff --git a/javax/net/ssl/SSLPermission.java b/javax/net/ssl/SSLPermission.java
index 3771eaf98..0fa4a591b 100644
--- a/javax/net/ssl/SSLPermission.java
+++ b/javax/net/ssl/SSLPermission.java
@@ -43,7 +43,7 @@ import java.security.BasicPermission;
/**
* A permission used for accessing SSL classes.
*/
-public class SSLPermission extends BasicPermission
+public final class SSLPermission extends BasicPermission
{
// Constant.
diff --git a/javax/print/DocFlavor.java b/javax/print/DocFlavor.java
index 381e2885e..11cc36d1a 100644
--- a/javax/print/DocFlavor.java
+++ b/javax/print/DocFlavor.java
@@ -217,7 +217,9 @@ public class DocFlavor implements Cloneable, Serializable
private static final long serialVersionUID = -4512080796965449721L;
- public static final String hostEncoding = "US-ASCII";
+ // FIXME: Get the host encoding from somewhere. Note that the new String is to make
+ // sure the field won't be a compile time constant.
+ public static final String hostEncoding = new String("US-ASCII");
private String mediaSubtype;
private String mediaType;
diff --git a/javax/print/attribute/AttributeSetUtilities.java b/javax/print/attribute/AttributeSetUtilities.java
index 3c72480c0..32bee51b6 100644
--- a/javax/print/attribute/AttributeSetUtilities.java
+++ b/javax/print/attribute/AttributeSetUtilities.java
@@ -41,6 +41,11 @@ import java.io.Serializable;
public final class AttributeSetUtilities
{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private AttributeSetUtilities() {}
+
private static class UnmodifiableAttributeSet
implements AttributeSet, Serializable
{
@@ -120,7 +125,7 @@ public final class AttributeSetUtilities
}
}
- public static class UnmodifiableDocAttributeSet
+ private static class UnmodifiableDocAttributeSet
extends UnmodifiableAttributeSet
implements DocAttributeSet, Serializable
{
@@ -130,7 +135,7 @@ public final class AttributeSetUtilities
}
}
- public static class UnmodifiablePrintJobAttributeSet
+ private static class UnmodifiablePrintJobAttributeSet
extends UnmodifiableAttributeSet
implements PrintJobAttributeSet, Serializable
{
@@ -140,7 +145,7 @@ public final class AttributeSetUtilities
}
}
- public static class UnmodifiablePrintRequestAttributeSet
+ private static class UnmodifiablePrintRequestAttributeSet
extends UnmodifiableAttributeSet
implements PrintRequestAttributeSet, Serializable
{
@@ -150,7 +155,7 @@ public final class AttributeSetUtilities
}
}
- public static class UnmodifiablePrintServiceAttributeSet
+ private static class UnmodifiablePrintServiceAttributeSet
extends UnmodifiableAttributeSet
implements PrintServiceAttributeSet, Serializable
{
@@ -160,7 +165,7 @@ public final class AttributeSetUtilities
}
}
- public static class SynchronizedAttributeSet
+ private static class SynchronizedAttributeSet
implements AttributeSet, Serializable
{
private AttributeSet set;
@@ -239,7 +244,7 @@ public final class AttributeSetUtilities
}
}
- public static class SynchronizedDocAttributeSet
+ private static class SynchronizedDocAttributeSet
extends SynchronizedAttributeSet
implements DocAttributeSet, Serializable
{
@@ -249,7 +254,7 @@ public final class AttributeSetUtilities
}
}
- public static class SynchronizedPrintJobAttributeSet
+ private static class SynchronizedPrintJobAttributeSet
extends SynchronizedAttributeSet
implements PrintJobAttributeSet, Serializable
{
@@ -259,7 +264,7 @@ public final class AttributeSetUtilities
}
}
- public static class SynchronizedPrintRequestAttributeSet
+ private static class SynchronizedPrintRequestAttributeSet
extends SynchronizedAttributeSet
implements PrintRequestAttributeSet, Serializable
{
@@ -269,7 +274,7 @@ public final class AttributeSetUtilities
}
}
- public static class SynchronizedPrintServiceAttributeSet
+ private static class SynchronizedPrintServiceAttributeSet
extends SynchronizedAttributeSet
implements PrintServiceAttributeSet, Serializable
{
diff --git a/javax/security/auth/PrivateCredentialPermission.java b/javax/security/auth/PrivateCredentialPermission.java
index cc370ae17..c8573f79e 100644
--- a/javax/security/auth/PrivateCredentialPermission.java
+++ b/javax/security/auth/PrivateCredentialPermission.java
@@ -63,7 +63,7 @@ import java.util.StringTokenizer;
* <i>PrincipalName</i> is a string representing the principal, or the
* wildcard character.</p>
*/
-public class PrivateCredentialPermission extends Permission
+public final class PrivateCredentialPermission extends Permission
implements Serializable
{
/**
diff --git a/javax/swing/BorderFactory.java b/javax/swing/BorderFactory.java
index 0f5693b94..4f0a1ee4e 100644
--- a/javax/swing/BorderFactory.java
+++ b/javax/swing/BorderFactory.java
@@ -52,6 +52,11 @@ import javax.swing.border.TitledBorder;
public class BorderFactory
{
+ private BorderFactory()
+ {
+ // Do nothing.
+ }
+
/**
* Creates a line border withe the specified color.
*
diff --git a/javax/swing/DefaultSingleSelectionModel.java b/javax/swing/DefaultSingleSelectionModel.java
index 51fa3b0b6..0b1371ed9 100644
--- a/javax/swing/DefaultSingleSelectionModel.java
+++ b/javax/swing/DefaultSingleSelectionModel.java
@@ -79,7 +79,7 @@ public class DefaultSingleSelectionModel
/**
* getSelectedIndex
- * @returns int
+ * @return int
*/
public int getSelectedIndex ()
{
@@ -113,7 +113,7 @@ public class DefaultSingleSelectionModel
/**
* isSelected
- * @returns boolean
+ * @return boolean
*/
public boolean isSelected ()
{
@@ -122,7 +122,8 @@ public class DefaultSingleSelectionModel
/**
* addChangeListener
- * @param listener TODO
+ *
+ * @param listener the listener to add
*/
public void addChangeListener (ChangeListener listener)
{
@@ -131,7 +132,8 @@ public class DefaultSingleSelectionModel
/**
* removeChangeListener
- * @param listener TODO
+ *
+ * @param listener the listener to remove
*/
public void removeChangeListener (ChangeListener listener)
{
@@ -161,8 +163,12 @@ public class DefaultSingleSelectionModel
/**
* getListeners
- * @param listenerClass TODO
- * @returns EventListener[]
+ *
+ * @param listenerClass the type fo listener
+ *
+ * @return an array of listeners
+ *
+ * @since 1.3
*/
public EventListener[] getListeners (Class listenerClass)
{
@@ -171,6 +177,8 @@ public class DefaultSingleSelectionModel
/**
* getChangeListeners
+ *
+ * @since 1.4
*/
public ChangeListener[] getChangeListeners ()
{
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index b073604c1..c22c2b2e7 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -325,6 +325,8 @@ public abstract class JComponent extends Container implements Serializable
private ActionMap actionMap;
private InputVerifier inputVerifier;
+ private TransferHandler transferHandler;
+
/**
* A lock held during recursive painting; this is used to serialize
* access to the double buffer, and also to select the "top level"
@@ -862,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;
}
@@ -2069,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.
*
diff --git a/javax/swing/JDesktopPane.java b/javax/swing/JDesktopPane.java
index bece0ac7b..996aaf191 100644
--- a/javax/swing/JDesktopPane.java
+++ b/javax/swing/JDesktopPane.java
@@ -154,7 +154,10 @@ public class JDesktopPane extends JLayeredPane implements Accessible
// FIXME: Unsupported mode.
if (mode == OUTLINE_DRAG_MODE)
- throw new IllegalArgumentException("Outline drag modes are unsupported.");
+ {
+ // throw new IllegalArgumentException("Outline drag modes are unsupported.");
+ mode = LIVE_DRAG_MODE;
+ }
dragMode = mode;
}
diff --git a/javax/swing/JList.java b/javax/swing/JList.java
index d88a4db59..4ef044006 100644
--- a/javax/swing/JList.java
+++ b/javax/swing/JList.java
@@ -250,12 +250,10 @@ public class JList extends JComponent implements Accessible, Scrollable
*/
int visibleRowCount;
-
-
/**
* Fire a {@link ListSelectionEvent} to all the registered ListSelectionListeners.
*/
- void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
+ protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
{
ListSelectionEvent evt = new ListSelectionEvent(this, firstIndex, lastIndex, isAdjusting);
ListSelectionListener listeners[] = getListSelectionListeners();
@@ -265,7 +263,6 @@ public class JList extends JComponent implements Accessible, Scrollable
}
}
-
/**
* This private listener propagates {@link ListSelectionEvent} events
* from the list's "selectionModel" property to the list's {@link
@@ -365,12 +362,22 @@ public class JList extends JComponent implements Accessible, Scrollable
listListener = new ListListener();
setModel(new DefaultListModel());
- setSelectionModel(new DefaultListSelectionModel());
+ setSelectionModel(createSelectionModel());
updateUI();
}
/**
+ * Creates the default <code>ListSelectionModel</code>.
+ *
+ * @return the <code>ListSelectionModel</code>
+ */
+ protected ListSelectionModel createSelectionModel()
+ {
+ return new DefaultListSelectionModel();
+ }
+
+ /**
* Gets the value of the {@link #fixedCellHeight} property. This property
* may be <code>-1</code> to indicate that no cell height has been
* set. This property is also set implicitly when the
@@ -501,6 +508,11 @@ public class JList extends JComponent implements Accessible, Scrollable
return (ListSelectionListener[]) getListeners(ListSelectionListener.class);
}
+ public int getSelectionMode()
+ {
+ return selectionModel.getSelectionMode();
+ }
+
/**
* Sets the list's "selectionMode" property, which simply mirrors the
* same property on the list's {@link #selectionModel} property. This
@@ -1196,4 +1208,119 @@ public class JList extends JComponent implements Accessible, Scrollable
{
return false;
}
+
+ public int getAnchorSelectionIndex()
+ {
+ return selectionModel.getAnchorSelectionIndex();
+ }
+
+ public int getLeadSelectionIndex()
+ {
+ return selectionModel.getLeadSelectionIndex();
+ }
+
+ public int getMinSelectionIndex()
+ {
+ return selectionModel.getMaxSelectionIndex();
+ }
+
+ public int getMaxSelectionIndex()
+ {
+ return selectionModel.getMaxSelectionIndex();
+ }
+
+ public void clearSelection()
+ {
+ selectionModel.clearSelection();
+ }
+
+ public void setSelectionInterval(int anchor, int lead)
+ {
+ selectionModel.setSelectionInterval(anchor, lead);
+ }
+
+ public void addSelectionInterval(int anchor, int lead)
+ {
+ selectionModel.addSelectionInterval(anchor, lead);
+ }
+
+ public void removeSelectionInterval(int index0, int index1)
+ {
+ selectionModel.removeSelectionInterval(index0, index1);
+ }
+
+ /**
+ * Returns the value of the <code>valueIsAdjusting</code> property.
+ *
+ * @return the value
+ */
+ public boolean getValueIsAdjusting()
+ {
+ return valueIsAdjusting;
+ }
+
+ /**
+ * Sets the <code>valueIsAdjusting</code> property.
+ *
+ * @param isAdjusting the new value
+ */
+ public void setValueIsAdjusting(boolean isAdjusting)
+ {
+ valueIsAdjusting = isAdjusting;
+ }
+
+ /**
+ * Return the value of the <code>dragEnabled</code> property.
+ *
+ * @return the value
+ *
+ * @since 1.4
+ */
+ public boolean getDragEnabled()
+ {
+ return dragEnabled;
+ }
+
+ /**
+ * Set the <code>dragEnabled</code> property.
+ *
+ * @param enabled new value
+ *
+ * @since 1.4
+ */
+ public void setDragEnabled(boolean enabled)
+ {
+ dragEnabled = enabled;
+ }
+
+ /**
+ * Returns the layout orientation.
+ *
+ * @return the orientation, one of <code>JList.VERTICAL</code>,
+ * </code>JList.VERTICAL_WRAP</code> and <code>JList.HORIZONTAL_WRAP</code>
+ *
+ * @since 1.4
+ */
+ public int getLayoutOrientation()
+ {
+ return layoutOrientation;
+ }
+
+ /**
+ * Sets the layout orientation.
+ *
+ * @param orientation the orientation to set, one of <code>JList.VERTICAL</code>,
+ * </code>JList.VERTICAL_WRAP</code> and <code>JList.HORIZONTAL_WRAP</code>
+ *
+ * @since 1.4
+ */
+ public void setLayoutOrientation(int orientation)
+ {
+ if (layoutOrientation == orientation)
+ return;
+
+ int old = layoutOrientation;
+ layoutOrientation = orientation;
+ firePropertyChange("layoutOrientation", old, orientation);
+ }
}
diff --git a/javax/swing/JMenuItem.java b/javax/swing/JMenuItem.java
index caee1f942..06d29adbd 100644
--- a/javax/swing/JMenuItem.java
+++ b/javax/swing/JMenuItem.java
@@ -529,19 +529,20 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public void menuSelectionChanged(boolean changed)
{
+ Component parent = this.getParent();
if (changed)
{
model.setArmed(true);
- if (this.getParent() instanceof JPopupMenu)
- ((JPopupMenu) this.getParent()).setSelected(this);
+ if (parent != null && parent instanceof JPopupMenu)
+ ((JPopupMenu) parent).setSelected(this);
}
else
{
model.setArmed(false);
- if (this.getParent() instanceof JPopupMenu)
- ((JPopupMenu) this.getParent()).getSelectionModel().clearSelection();
+ if (parent != null && parent instanceof JPopupMenu)
+ ((JPopupMenu) parent).getSelectionModel().clearSelection();
}
}
diff --git a/javax/swing/JPasswordField.java b/javax/swing/JPasswordField.java
index 8d062a661..133c99ac3 100644
--- a/javax/swing/JPasswordField.java
+++ b/javax/swing/JPasswordField.java
@@ -91,8 +91,9 @@ public class JPasswordField extends JTextField
}
/**
- * Constructor JPasswordField
- * @param text TODO
+ * Creates a <code>JPasswordField</code> object.
+ *
+ * @param text the initial text
*/
public JPasswordField(String text)
{
@@ -100,8 +101,9 @@ public class JPasswordField extends JTextField
}
/**
- * Constructor JPasswordField
- * @param columns TODO
+ * Creates a <code>JPasswordField</code> object.
+ *
+ * @param columns the number of columns
*/
public JPasswordField(int columns)
{
@@ -109,9 +111,10 @@ public class JPasswordField extends JTextField
}
/**
- * Constructor JPasswordField
- * @param text TODO
- * @param columns TODO
+ * Creates a <code>JPasswordField</code> object.
+ *
+ * @param text the initial text
+ * @param columns the number of columns
*/
public JPasswordField(String text, int columns)
{
@@ -119,10 +122,11 @@ public class JPasswordField extends JTextField
}
/**
- * Constructor JPasswordField
- * @param document TODO
- * @param text TODO
- * @param columns TODO
+ * Creates a <code>JPasswordField</code> object.
+ *
+ * @param document the document to use
+ * @param text the initial text
+ * @param columns the number of columns
*/
public JPasswordField(Document document, String text, int columns)
{
@@ -131,17 +135,20 @@ public class JPasswordField extends JTextField
/**
* writeObject
- * @param stream TODO
- * @exception IOException TODO
+ *
+ * @param stream the stream to write to
+ *
+ * @exception IOException if an error occurs
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
- // TODO
+ // TODO: Implement me.
}
/**
- * getUIClassID
- * @return String
+ * Returns the <code>UIClassID</code>
+ *
+ * @return the string "PasswordFieldUI"
*/
public String getUIClassID()
{
@@ -150,7 +157,8 @@ public class JPasswordField extends JTextField
/**
* getEchoChar
- * @return char
+ *
+ * @return the echo char
*/
public char getEchoChar()
{
@@ -159,7 +167,8 @@ public class JPasswordField extends JTextField
/**
* setEchoChar
- * @param echo TODO
+ *
+ * @param echo the echo char
*/
public void setEchoChar(char echo)
{
@@ -168,7 +177,9 @@ public class JPasswordField extends JTextField
/**
* echoCharIsSet
- * @return boolean
+ *
+ * @return <code>true</code> if the echo char is set,
+ * <code>false</code> otherwise.
*/
public boolean echoCharIsSet()
{
@@ -176,7 +187,8 @@ public class JPasswordField extends JTextField
}
/**
- * copy
+ * Copies the selected text into the clipboard. This operation is not
+ * allowed in a password input field.
*/
public void copy()
{
@@ -184,7 +196,8 @@ public class JPasswordField extends JTextField
}
/**
- * cut
+ * Cuts the selected text and puts it into the clipboard. This operation
+ * is not allowed in a password input field.
*/
public void cut()
{
@@ -193,7 +206,9 @@ public class JPasswordField extends JTextField
/**
* getText
+ *
* @return String
+ *
* @deprecated
*/
public String getText()
@@ -203,10 +218,14 @@ public class JPasswordField extends JTextField
/**
* getText
+ *
* @param offset TODO
* @param length TODO
+ *
* @return String
+ *
* @exception BadLocationException TODO
+ *
* @deprecated
*/
public String getText(int offset, int length) throws BadLocationException
@@ -216,6 +235,7 @@ public class JPasswordField extends JTextField
/**
* getPassword
+ *
* @return char[]
*/
public char[] getPassword()
@@ -225,6 +245,7 @@ public class JPasswordField extends JTextField
/**
* paramString
+ *
* @return String
*/
protected String paramString()
@@ -234,7 +255,8 @@ public class JPasswordField extends JTextField
/**
* getAccessibleContext
- * @return AccessibleContext
+ *
+ * @return the <code>AccessibleContext</code> object
*/
public AccessibleContext getAccessibleContext()
{
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index b0ee35336..b2b5a8393 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -675,6 +675,11 @@ public class JTable extends JComponent
return renderer;
}
+ public void setDefaultRenderer(Class columnClass, TableCellRenderer rend)
+ {
+ defaultRenderersByColumnClass.put(columnClass, rend);
+ }
+
public TableCellRenderer getDefaultRenderer(Class columnClass)
{
if (defaultRenderersByColumnClass.containsKey(columnClass))
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 20605f791..2329d24dd 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -40,7 +40,9 @@ package javax.swing;
import java.awt.Dimension;
import java.awt.Rectangle;
+import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.Vector;
import javax.accessibility.Accessible;
@@ -52,6 +54,9 @@ import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeWillExpandListener;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.ExpandVetoException;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellEditor;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
@@ -59,6 +64,7 @@ import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
+
public class JTree extends JComponent
implements Scrollable, Accessible
{
@@ -81,6 +87,11 @@ public class JTree extends JComponent
public static final String TREE_MODEL_PROPERTY = "model";
public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount";
+ private boolean dragEnabled;
+ private boolean expandsSelectedPaths;
+ private TreePath anchorSelectionPath;
+ private TreePath leadSelectionPath;
+
protected TreeCellEditor cellEditor;
protected TreeCellRenderer cellRenderer;
protected boolean editable;
@@ -100,7 +111,7 @@ public class JTree extends JComponent
*/
public JTree()
{
- treeModel = createTreeModel(null);
+ this(createTreeModel(null));
}
/**
@@ -110,7 +121,7 @@ public class JTree extends JComponent
*/
public JTree(Hashtable value)
{
- treeModel = createTreeModel(value);
+ this(createTreeModel(value));
}
/**
@@ -120,7 +131,7 @@ public class JTree extends JComponent
*/
public JTree(Object[] value)
{
- treeModel = createTreeModel(value);
+ this(createTreeModel(value));
}
/**
@@ -131,6 +142,8 @@ public class JTree extends JComponent
public JTree(TreeModel model)
{
treeModel = model;
+ setCellRenderer(new DefaultTreeCellRenderer());
+ updateUI();
}
/**
@@ -152,6 +165,7 @@ public class JTree extends JComponent
*/
public JTree(TreeNode root, boolean asksAllowChildren)
{
+ this(new DefaultTreeModel(root, asksAllowChildren));
}
/**
@@ -161,9 +175,116 @@ public class JTree extends JComponent
*/
public JTree(Vector value)
{
- treeModel = createTreeModel(value);
+ this(createTreeModel(value));
+ }
+
+ public static class DynamicUtilTreeNode
+ extends DefaultMutableTreeNode
+ {
+ protected Object childValue;
+ protected boolean loadedChildren;
+ public DynamicUtilTreeNode(Object value,
+ Object children)
+ {
+ super(value);
+ childValue = children;
+ loadedChildren = false;
+ }
+
+ public int getChildCount()
+ {
+ loadChildren();
+ return super.getChildCount();
+ }
+
+ protected void loadChildren()
+ {
+ if (!loadedChildren)
+ {
+ createChildren(this, childValue);
+ loadedChildren = true;
+ }
+ }
+
+ public Enumeration children()
+ {
+ loadChildren();
+ return super.children();
+ }
+
+ public boolean isLeaf()
+ {
+ return (childValue == null ||
+ !(childValue instanceof Hashtable
+ || childValue instanceof Vector
+ || childValue.getClass().isArray()));
+ }
+
+ public static void createChildren(DefaultMutableTreeNode parent,
+ Object children)
+ {
+ if (children instanceof Hashtable)
+ {
+ Hashtable tab = (Hashtable) children;
+ Enumeration e = tab.keys();
+ while (e.hasMoreElements())
+ {
+ Object key = e.nextElement();
+ Object val = tab.get(key);
+ parent.add(new DynamicUtilTreeNode(key, val));
+ }
+ }
+ else if (children instanceof Vector)
+ {
+ Iterator i = ((Vector)children).iterator();
+ while (i.hasNext())
+ {
+ Object n = i.next();
+ parent.add(new DynamicUtilTreeNode(n,n));
+ }
+ }
+ else if (children.getClass().isArray())
+ {
+ Object[] arr = (Object[]) children;
+ for (int i = 0; i < arr.length; ++i)
+ parent.add(new DynamicUtilTreeNode(arr[i], arr[i]));
+ }
+ }
+ }
+
+ public int getRowForPath(TreePath path)
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getRowForPath(this, path);
+
+ return -1;
+ }
+
+ public TreePath getPathForRow(int row)
+ {
+ TreeUI ui = getUI();
+ return ui != null ? ui.getPathForRow(this, row) : null;
}
+ protected TreePath[] getPathBetweenRows(int index0, int index1)
+ {
+ TreeUI ui = getUI();
+
+ if (ui == null)
+ return null;
+
+ int minIndex = Math.min(index0, index1);
+ int maxIndex = Math.max(index0, index1);
+ TreePath[] paths = new TreePath[maxIndex - minIndex + 1];
+
+ for (int i = minIndex; i <= maxIndex; ++i)
+ paths[i - minIndex] = ui.getPathForRow(this, i);
+
+ return paths;
+ }
+
/**
* Creates a new <code>TreeModel</code> object.
*
@@ -171,8 +292,7 @@ public class JTree extends JComponent
*/
protected static TreeModel createTreeModel(Object value)
{
- // FIXME: Implement this.
- return null;
+ return new DefaultTreeModel(new DynamicUtilTreeNode(value, value));
}
/**
@@ -201,6 +321,8 @@ public class JTree extends JComponent
public void updateUI()
{
setUI((TreeUI) UIManager.getUI(this));
+ revalidate();
+ repaint();
}
/**
@@ -433,7 +555,12 @@ public class JTree extends JComponent
*/
public void setModel(TreeModel model)
{
+ if (treeModel == model)
+ return;
+
+ TreeModel oldValue = treeModel;
treeModel = model;
+ firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
}
/**
@@ -460,7 +587,7 @@ public class JTree extends JComponent
boolean oldValue = editable;
editable = flag;
- firePropertyChange("editable", oldValue, editable);
+ firePropertyChange(EDITABLE_PROPERTY, oldValue, editable);
}
/**
@@ -476,7 +603,12 @@ public class JTree extends JComponent
public void setRootVisible(boolean flag)
{
+ if (rootVisible == flag)
+ return;
+
+ boolean oldValue = rootVisible;
rootVisible = flag;
+ firePropertyChange(ROOT_VISIBLE_PROPERTY, oldValue, flag);
}
public boolean getShowsRootHandles()
@@ -486,7 +618,12 @@ public class JTree extends JComponent
public void setShowsRootHandles(boolean flag)
{
+ if (showsRootHandles == flag)
+ return;
+
+ boolean oldValue = showsRootHandles;
showsRootHandles = flag;
+ firePropertyChange(SHOWS_ROOT_HANDLES_PROPERTY, oldValue, flag);
}
public TreeCellEditor getCellEditor()
@@ -496,7 +633,12 @@ public class JTree extends JComponent
public void setCellEditor(TreeCellEditor editor)
{
+ if (cellEditor == editor)
+ return;
+
+ TreeCellEditor oldValue = cellEditor;
cellEditor = editor;
+ firePropertyChange(CELL_EDITOR_PROPERTY, oldValue, editor);
}
public TreeCellRenderer getCellRenderer()
@@ -506,7 +648,12 @@ public class JTree extends JComponent
public void setCellRenderer(TreeCellRenderer newRenderer)
{
+ if (cellRenderer == newRenderer)
+ return;
+
+ TreeCellRenderer oldValue = cellRenderer;
cellRenderer = newRenderer;
+ firePropertyChange(CELL_RENDERER_PROPERTY, oldValue, newRenderer);
}
public TreeSelectionModel getSelectionModel()
@@ -516,7 +663,12 @@ public class JTree extends JComponent
public void setSelectionModel(TreeSelectionModel model)
{
+ if (selectionModel == model)
+ return;
+
+ TreeSelectionModel oldValue = selectionModel;
selectionModel = model;
+ firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, model);
}
public int getVisibleRowCount()
@@ -526,7 +678,12 @@ public class JTree extends JComponent
public void setVisibleRowCount(int rows)
{
+ if (visibleRowCount == rows)
+ return;
+
+ int oldValue = visibleRowCount;
visibleRowCount = rows;
+ firePropertyChange(VISIBLE_ROW_COUNT_PROPERTY, oldValue, rows);
}
public boolean isLargeModel()
@@ -536,7 +693,12 @@ public class JTree extends JComponent
public void setLargeModel(boolean large)
{
+ if (largeModel == large)
+ return;
+
+ boolean oldValue = largeModel;
largeModel = large;
+ firePropertyChange(LARGE_MODEL_PROPERTY, oldValue, large);
}
public int getRowHeight()
@@ -546,7 +708,17 @@ public class JTree extends JComponent
public void setRowHeight(int height)
{
+ if (rowHeight == height)
+ return;
+
+ int oldValue = rowHeight;
rowHeight = height;
+ firePropertyChange(ROW_HEIGHT_PROPERTY, oldValue, height);
+ }
+
+ public boolean isFixedRowHeight()
+ {
+ return rowHeight > 0;
}
public boolean getInvokesStopCellEditing()
@@ -556,7 +728,12 @@ public class JTree extends JComponent
public void setInvokesStopCellEditing(boolean invoke)
{
+ if (invokesStopCellEditing == invoke)
+ return;
+
+ boolean oldValue = invokesStopCellEditing;
invokesStopCellEditing = invoke;
+ firePropertyChange(INVOKES_STOP_CELL_EDITING_PROPERTY, oldValue, invoke);
}
/**
@@ -572,7 +749,12 @@ public class JTree extends JComponent
*/
public void setToggleClickCount(int count)
{
+ if (toggleClickCount == count)
+ return;
+
+ int oldValue = toggleClickCount;
toggleClickCount = count;
+ firePropertyChange(TOGGLE_CLICK_COUNT_PROPERTY, oldValue, count);
}
public boolean getScrollsOnExpand()
@@ -582,6 +764,401 @@ public class JTree extends JComponent
public void setScrollsOnExpand(boolean scroll)
{
+ if (scrollsOnExpand == scroll)
+ return;
+
+ boolean oldValue = scrollsOnExpand;
scrollsOnExpand = scroll;
+ firePropertyChange(SCROLLS_ON_EXPAND_PROPERTY, oldValue, scroll);
+ }
+
+ public void setSelectionPath(TreePath path)
+ {
+ selectionModel.setSelectionPath(path);
+ }
+
+ public void setSelectionPaths(TreePath[] paths)
+ {
+ selectionModel.setSelectionPaths(paths);
+ }
+
+ public void setSelectionRow(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ selectionModel.setSelectionPath(path);
+ }
+
+ public void setSelectionRows(int[] rows)
+ {
+ // Make sure we have an UI so getPathForRow() does not return null.
+ if (rows == null || getUI() == null)
+ return;
+
+ TreePath[] paths = new TreePath[rows.length];
+
+ for (int i = rows.length - 1; i >= 0; --i)
+ paths[i] = getPathForRow(rows[i]);
+
+ setSelectionPaths(paths);
+ }
+
+ public void setSelectionInterval(int index0, int index1)
+ {
+ TreePath[] paths = getPathBetweenRows(index0, index1);
+
+ if (paths != null)
+ setSelectionPaths(paths);
+ }
+
+ public void addSelectionPath(TreePath path)
+ {
+ selectionModel.addSelectionPath(path);
+ }
+
+ public void addSelectionPaths(TreePath[] paths)
+ {
+ selectionModel.addSelectionPaths(paths);
+ }
+
+ public void addSelectionRow(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ selectionModel.addSelectionPath(path);
+ }
+
+ public void addSelectionRows(int[] rows)
+ {
+ // Make sure we have an UI so getPathForRow() does not return null.
+ if (rows == null || getUI() == null)
+ return;
+
+ TreePath[] paths = new TreePath[rows.length];
+
+ for (int i = rows.length - 1; i >= 0; --i)
+ paths[i] = getPathForRow(rows[i]);
+
+ addSelectionPaths(paths);
+ }
+
+ public void addSelectionInterval(int index0, int index1)
+ {
+ TreePath[] paths = getPathBetweenRows(index0, index1);
+
+ if (paths != null)
+ addSelectionPaths(paths);
+ }
+
+ public void removeSelectionPath(TreePath path)
+ {
+ selectionModel.removeSelectionPath(path);
+ }
+
+ public void removeSelectionPaths(TreePath[] paths)
+ {
+ selectionModel.removeSelectionPaths(paths);
+ }
+
+ public void removeSelectionRow(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ selectionModel.removeSelectionPath(path);
+ }
+
+ public void removeSelectionRows(int[] rows)
+ {
+ // Make sure we have an UI so getPathForRow() does not return null.
+ if (rows == null || getUI() == null)
+ return;
+
+ TreePath[] paths = new TreePath[rows.length];
+
+ for (int i = rows.length - 1; i >= 0; --i)
+ paths[i] = getPathForRow(rows[i]);
+
+ removeSelectionPaths(paths);
+ }
+
+ public void removeSelectionInterval(int index0, int index1)
+ {
+ TreePath[] paths = getPathBetweenRows(index0, index1);
+
+ if (paths != null)
+ removeSelectionPaths(paths);
+ }
+
+ public void clearSelection()
+ {
+ selectionModel.clearSelection();
+ }
+
+ public TreePath getLeadSelectionPath()
+ {
+ return leadSelectionPath;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setLeadSelectionPath(TreePath path)
+ {
+ if (leadSelectionPath == path)
+ return;
+
+ TreePath oldValue = leadSelectionPath;
+ leadSelectionPath = path;
+ firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, path);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public TreePath getAnchorSelectionPath()
+ {
+ return anchorSelectionPath;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setAnchorSelectionPath(TreePath path)
+ {
+ if (anchorSelectionPath == path)
+ return;
+
+ TreePath oldValue = anchorSelectionPath;
+ anchorSelectionPath = path;
+ firePropertyChange(ANCHOR_SELECTION_PATH_PROPERTY, oldValue, path);
+ }
+
+ public int getLeadSelectionRow()
+ {
+ return selectionModel.getLeadSelectionRow();
+ }
+
+ public int getMaxSelectionRow()
+ {
+ return selectionModel.getMaxSelectionRow();
+ }
+
+ public int getMinSelectionRow()
+ {
+ return selectionModel.getMinSelectionRow();
+ }
+
+ public int getSelectionCount()
+ {
+ return selectionModel.getSelectionCount();
+ }
+
+ public TreePath getSelectionPath()
+ {
+ return selectionModel.getSelectionPath();
+ }
+
+ public TreePath[] getSelectionPaths()
+ {
+ return selectionModel.getSelectionPaths();
+ }
+
+ public int[] getSelectionRows()
+ {
+ return selectionModel.getSelectionRows();
+ }
+
+ public boolean isPathSelected(TreePath path)
+ {
+ return selectionModel.isPathSelected(path);
+ }
+
+ public boolean isRowSelected(int row)
+ {
+ return selectionModel.isRowSelected(row);
+ }
+
+ public boolean isSelectionEmpty()
+ {
+ return selectionModel.isSelectionEmpty();
+ }
+
+ /**
+ * Return the value of the <code>dragEnabled</code> property.
+ *
+ * @return the value
+ *
+ * @since 1.4
+ */
+ public boolean getDragEnabled()
+ {
+ return dragEnabled;
+ }
+
+ /**
+ * Set the <code>dragEnabled</code> property.
+ *
+ * @param enabled new value
+ *
+ * @since 1.4
+ */
+ public void setDragEnabled(boolean enabled)
+ {
+ dragEnabled = enabled;
+ }
+
+ public int getRowCount()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getRowCount(this);
+
+ return 0;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public boolean getExpandsSelectedPaths()
+ {
+ return expandsSelectedPaths;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setExpandsSelectedPaths(boolean flag)
+ {
+ if (expandsSelectedPaths == flag)
+ return;
+
+ boolean oldValue = expandsSelectedPaths;
+ expandsSelectedPaths = flag;
+ firePropertyChange(EXPANDS_SELECTED_PATHS_PROPERTY, oldValue, flag);
+ }
+
+ public Rectangle getPathBounds(TreePath path)
+ {
+ TreeUI ui = getUI();
+
+ if (ui == null)
+ return null;
+
+ return ui.getPathBounds(this, path);
+ }
+
+ public Rectangle getRowBounds(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ return getPathBounds(path);
+
+ return null;
+ }
+
+ public boolean isEditing()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.isEditing(this);
+
+ return false;
+ }
+
+ public boolean stopEditing()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.stopEditing(this);
+
+ return false;
+ }
+
+ public void cancelEditing()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ ui.cancelEditing(this);
+ }
+
+ public void startEditingAtPath(TreePath path)
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ ui.startEditingAtPath(this, path);
+ }
+
+ public TreePath getEditingPath()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getEditingPath(this);
+
+ return null;
+ }
+
+ public TreePath getPathForLocation(int x, int y)
+ {
+ TreePath path = getClosestPathForLocation(x, y);
+
+ if (path != null)
+ {
+ Rectangle rect = getPathBounds(path);
+
+ if ((rect != null) && rect.contains(x, y))
+ return path;
+ }
+
+ return null;
+ }
+
+ public int getRowForLocation(int x, int y)
+ {
+ TreePath path = getPathForLocation(x, y);
+
+ if (path != null)
+ return getRowForPath(path);
+
+ return -1;
+ }
+
+ public TreePath getClosestPathForLocation(int x, int y)
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getClosestPathForLocation(this, x, y);
+
+ return null;
+ }
+
+ public int getClosestRowForLocation(int x, int y)
+ {
+ TreePath path = getClosestPathForLocation(x, y);
+
+ if (path != null)
+ return getRowForPath(path);
+
+ return -1;
+ }
+
+ public Object getLastSelectedPathComponent()
+ {
+ TreePath path = getSelectionPath();
+
+ if (path != null)
+ return path.getLastPathComponent();
+
+ return null;
}
}
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index 102b0100a..9b26c8b21 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -127,6 +127,7 @@ public class JViewport extends JComponent
public JViewport()
{
setOpaque(true);
+ setScrollMode(BLIT_SCROLL_MODE);
updateUI();
}
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index 5d2b130da..c29ba787e 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -309,6 +309,9 @@ public class RepaintManager
public synchronized void addDirtyRegion(JComponent component, int x, int y,
int w, int h)
{
+ if (w == 0 || h == 0)
+ return;
+
Rectangle r = new Rectangle(x, y, w, h);
if (dirtyComponents.containsKey(component))
r = r.union((Rectangle)dirtyComponents.get(component));
diff --git a/javax/swing/ScrollPaneLayout.java b/javax/swing/ScrollPaneLayout.java
index 7d7620bda..899f39f7f 100644
--- a/javax/swing/ScrollPaneLayout.java
+++ b/javax/swing/ScrollPaneLayout.java
@@ -321,7 +321,6 @@ public class ScrollPaneLayout
insetsSize.setSize(insets.left + insets.right,
insets.top + insets.bottom);
- maybeSetMinimumSize(viewport, viewportSize);
maybeSetMinimumSize(colHead, columnHeaderSize);
maybeSetMinimumSize(rowHead, rowHeaderSize);
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index 55c8f6cf4..feacf4fca 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -76,6 +76,11 @@ public class SwingUtilities implements SwingConstants
*/
private static OwnerFrame ownerFrame;
+ private SwingUtilities()
+ {
+ // Do nothing.
+ }
+
/**
* Calculates the portion of the base rectangle which is inside the
* insets.
@@ -1015,4 +1020,170 @@ public class SwingUtilities implements SwingConstants
child.setParent(uiInputMap);
}
}
+
+ /**
+ * Subtracts a rectangle from another and return the area as an array
+ * of rectangles.
+ * Returns the areas of rectA which are not covered by rectB.
+ * If the rectangles do not overlap, or if either parameter is
+ * <code>null</code>, a zero-size array is returned.
+ * @param rectA The first rectangle
+ * @param rectB The rectangle to subtract from the first
+ * @return An array of rectangles representing the area in rectA
+ * not overlapped by rectB
+ */
+ public static Rectangle[] computeDifference(Rectangle rectA, Rectangle rectB)
+ {
+ if (rectA == null || rectB == null)
+ return new Rectangle[0];
+
+ Rectangle[] r = new Rectangle[4];
+ int x1 = rectA.x;
+ int y1 = rectA.y;
+ int w1 = rectA.width;
+ int h1 = rectA.height;
+ int x2 = rectB.x;
+ int y2 = rectB.y;
+ int w2 = rectB.width;
+ int h2 = rectB.height;
+
+ // (outer box = rectA)
+ // -------------
+ // |_____0_____|
+ // | |rectB| |
+ // |_1|_____|_2|
+ // | 3 |
+ // -------------
+ int H0 = (y2 > y1) ? y2 - y1 : 0; // height of box 0
+ int H3 = (y2 + h2 < y1 + h1) ? y1 + h1 - y2 - h2 : 0; // height box 3
+ int W1 = (x2 > x1) ? x2 - x1 : 0; // width box 1
+ int W2 = (x1 + w1 > x2 + w2) ? x1 + w1 - x2 - w2 : 0; // w. box 2
+ int H12 = (H0 + H3 < h1) ? h1 - H0 - H3 : 0; // height box 1 & 2
+
+ if (H0 > 0)
+ r[0] = new Rectangle(x1, y1, w1, H0);
+ else
+ r[0] = null;
+
+ if (W1 > 0 && H12 > 0)
+ r[1] = new Rectangle(x1, y1 + H0, W1, H12);
+ else
+ r[1] = null;
+
+ if (W2 > 0 && H12 > 0)
+ r[2] = new Rectangle(x2 + w2, y1 + H0, W2, H12);
+ else
+ r[2] = null;
+
+ if (H3 > 0)
+ r[3] = new Rectangle(x1, y1 + H0 + H12, w1, H3);
+ else
+ r[3] = null;
+
+ // sort out null objects
+ int n = 0;
+ for (int i = 0; i < 4; i++)
+ if (r[i] != null)
+ n++;
+ Rectangle[] out = new Rectangle[n];
+ for (int i = 3; i >= 0; i--)
+ if (r[i] != null)
+ out[--n] = r[i];
+
+ return out;
+ }
+
+ /**
+ * Calculates the intersection of two rectangles.
+ *
+ * @param x upper-left x coodinate of first rectangle
+ * @param x upper-left y coodinate of first rectangle
+ * @param w width of first rectangle
+ * @param h height of first rectangle
+ * @param rect a Rectangle object of the second rectangle
+ * @throws a NullPointerException if rect is null.
+ *
+ * @return a rectangle corresponding to the intersection of the
+ * two rectangles. A zero rectangle is returned if the rectangles
+ * do not overlap.
+ */
+ public static Rectangle computeIntersection(int x, int y, int w, int h,
+ Rectangle rect)
+ {
+ int x2 = (int) rect.getX();
+ int y2 = (int) rect.getY();
+ int w2 = (int) rect.getWidth();
+ int h2 = (int) rect.getHeight();
+
+ int dx = (x > x2) ? x : x2;
+ int dy = (y > y2) ? y : y2;
+ int dw = (x + w < x2 + w2) ? (x + w - dx) : (x2 + w2 - dx);
+ int dh = (y + h < y2 + h2) ? (y + h - dy) : (y2 + h2 - dy);
+
+ if (dw >= 0 && dh >= 0)
+ return new Rectangle(dx, dy, dw, dh);
+
+ return new Rectangle(0, 0, 0, 0);
+ }
+
+ /**
+ * Calculates the width of a given string.
+ *
+ * @param fm the <code>FontMetrics</code> object to use
+ * @param str the string
+ *
+ * @return the width of the the string.
+ */
+ public static int computeStringWidth(FontMetrics fm, String str)
+ {
+ return fm.stringWidth(str);
+ }
+
+ /**
+ * Calculates the union of two rectangles.
+ *
+ * @param x upper-left x coodinate of first rectangle
+ * @param x upper-left y coodinate of first rectangle
+ * @param w width of first rectangle
+ * @param h height of first rectangle
+ * @param rect a Rectangle object of the second rectangle
+ * @throws a NullPointerException if rect is null.
+ *
+ * @return a rectangle corresponding to the union of the
+ * two rectangles. A rectangle encompassing both is returned if the
+ * rectangles do not overlap.
+ */
+ public static Rectangle computeUnion(int x, int y, int w, int h,
+ Rectangle rect)
+ {
+ int x2 = (int) rect.getX();
+ int y2 = (int) rect.getY();
+ int w2 = (int) rect.getWidth();
+ int h2 = (int) rect.getHeight();
+
+ int dx = (x < x2) ? x : x2;
+ int dy = (y < y2) ? y : y2;
+ int dw = (x + w > x2 + w2) ? (x + w - dx) : (x2 + w2 - dx);
+ int dh = (y + h > y2 + h2) ? (y + h - dy) : (y2 + h2 - dy);
+
+ if (dw >= 0 && dh >= 0)
+ return new Rectangle(dx, dy, dw, dh);
+
+ return new Rectangle(0, 0, 0, 0);
+ }
+
+ /**
+ * Tests if a rectangle contains another.
+ * @param a first rectangle
+ * @param b second rectangle
+ * @return true if a contains b, false otherwise
+ * @throws NullPointerException
+ */
+ public static boolean isRectangleContainingRectangle(Rectangle a, Rectangle b)
+ {
+ // Note: zero-size rects inclusive, differs from Rectangle.contains()
+ return b.width >= 0 && b.height >= 0 && b.width >= 0 && b.height >= 0
+ && b.x >= a.x && b.x + b.width <= a.x + a.width && b.y >= a.y
+ && b.y + b.height <= a.y + a.height;
+ }
}
diff --git a/javax/swing/ToolTipManager.java b/javax/swing/ToolTipManager.java
index 314ecd507..6245786af 100644
--- a/javax/swing/ToolTipManager.java
+++ b/javax/swing/ToolTipManager.java
@@ -452,7 +452,13 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
{
currentPoint = event.getPoint();
if (currentTip != null)
- currentTip.setTipText(((JComponent) currentComponent).getToolTipText(event));
+ {
+ if (currentComponent == null)
+ currentComponent = (Component) event.getSource();
+
+ String text = ((JComponent) currentComponent).getToolTipText(event);
+ currentTip.setTipText(text);
+ }
if (enterTimer.isRunning())
enterTimer.restart();
}
@@ -464,7 +470,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
private void showTip()
{
- if (! enabled)
+ if (! enabled || currentComponent == null)
return;
if (currentTip == null
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index e64df9c4c..16b5016b3 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
import java.io.Serializable;
+import java.awt.event.InputEvent;
+import java.awt.datatransfer.*;
public class TransferHandler implements Serializable
{
@@ -48,8 +50,66 @@ public class TransferHandler implements Serializable
public static final int MOVE = 2;
public static final int COPY_OR_MOVE = 3;
+ static Action getCopyAction ()
+ {
+ return null;
+ }
+
+ static Action getCutAction ()
+ {
+ return null;
+ }
+
+ static Action getPasteAction ()
+ {
+ return null;
+ }
+
+
protected TransferHandler()
{
// Do nothing here.
}
+
+ public TransferHandler(String property)
+ {
+ }
+
+ public boolean canImport (JComponent c, DataFlavor[] flavors)
+ {
+ return false;
+ }
+
+ public Transferable createTransferable(JComponent c)
+ {
+ return null;
+ }
+
+ public void exportAsDrag (JComponent c, InputEvent e, int action)
+ {
+ }
+
+ protected void exportDone (JComponent c, Transferable data, int action)
+ {
+ }
+
+ public void exportToClipboard(JComponent c, Clipboard clip, int action)
+ {
+ }
+
+ public int getSourceActions (JComponent c)
+ {
+ return 0;
+ }
+
+ public Icon getVisualRepresentation (Transferable t)
+ {
+ return null;
+ }
+
+ public boolean importData (JComponent c, Transferable t)
+ {
+ return false;
+ }
+
}
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 7fd5fa004..40bf972f2 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -138,6 +138,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI",
"TableHeaderUI", "javax.swing.plaf.basic.BasicTableHeaderUI",
"TableUI", "javax.swing.plaf.basic.BasicTableUI",
+ "TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
"TextAreaUI", "javax.swing.plaf.basic.BasicTextAreaUI",
"TextFieldUI", "javax.swing.plaf.basic.BasicTextFieldUI",
"TextPaneUI", "javax.swing.plaf.basic.BasicTextPaneUI",
@@ -901,8 +902,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"Tree.background", new ColorUIResource(Color.white),
"Tree.changeSelectionWithFocus", Boolean.TRUE,
- // XXX Don't use gif
- "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.gif")),
+ "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.png")),
+ "Tree.collapsedIcon", new IconUIResource(new ImageIcon("icons/TreeCollapsed.png")),
"Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
"Tree.editorBorder", new BorderUIResource.LineBorderUIResource(Color.lightGray),
"Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
@@ -950,13 +951,12 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl PAGE_DOWN", "scrollDownChangeLead"
}),
"Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Tree.expandedIcon", new IconUIResource(new ImageIcon("icons/TreeExpanded.png")),
"Tree.foreground", new ColorUIResource(Color.black),
"Tree.hash", new ColorUIResource(Color.gray),
- // XXX Don't use gif
- "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.gif")),
+ "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.png")),
"Tree.leftChildIndent", new Integer(7),
- // XXX Don't use gif
- "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.gif")),
+ "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.png")),
"Tree.rightChildIndent", new Integer(13),
"Tree.rowHeight", new Integer(16),
"Tree.scrollsOnExpand", Boolean.TRUE,
diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java
index 4df257f7e..ff48a74f0 100644
--- a/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -60,6 +60,7 @@ import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -392,6 +393,9 @@ public class BasicMenuItemUI extends MenuItemUI
selectionBackground = defaults.getColor("MenuItem.selectionBackground");
selectionForeground = defaults.getColor("MenuItem.selectionForeground");
acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
+
+ menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
+ menuItem.setHorizontalAlignment(SwingConstants.LEADING);
}
/**
@@ -551,23 +555,14 @@ public class BasicMenuItemUI extends MenuItemUI
}
}
- // paint icon
- // FIXME: should paint different icon at different button state's.
- // i.e disabled icon when button is disabled.. etc.
- Icon i = m.getIcon();
- if (i != null)
- {
- i.paintIcon(c, g, vr.x, vr.y);
-
- // Adjust view rectangle, s.t text would be drawn after menu item's icon.
- vr.x += i.getIconWidth() + defaultTextIconGap;
- }
-
// paint text and user menu icon if it exists
- SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),
+ Icon i = m.getIcon();
+ SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i,
vertAlign, horAlign, vertTextPos,
horTextPos, vr, ir, tr,
defaultTextIconGap);
+ if (i != null)
+ i.paintIcon(c, g, ir.x, ir.y);
paintText(g, m, tr, m.getText());
diff --git a/javax/swing/plaf/basic/BasicTableHeaderUI.java b/javax/swing/plaf/basic/BasicTableHeaderUI.java
index 5b28b5d9f..ea7dfc0cd 100644
--- a/javax/swing/plaf/basic/BasicTableHeaderUI.java
+++ b/javax/swing/plaf/basic/BasicTableHeaderUI.java
@@ -181,84 +181,6 @@ public class BasicTableHeaderUI
}
}
-
- public Dimension getMaximumSize(JComponent c)
- {
- TableColumnModel cmod = header.getColumnModel();
- TableCellRenderer defaultRend = header.getDefaultRenderer();
- int ncols = cmod.getColumnCount();
- int spacing = 0;
- Dimension ret = getPreferredSize(c);
-
- if (header.getTable() != null
- && header.getTable().getInterCellSpacing() != null)
- spacing = header.getTable().getInterCellSpacing().width;
-
- ret.width = 0;
- for (int i = 0; i < ncols; ++i)
- {
- TableColumn col = cmod.getColumn(i);
- TableCellRenderer rend = col.getHeaderRenderer();
- if (rend == null)
- rend = defaultRend;
- Object val = col.getHeaderValue();
- Component comp = rend.getTableCellRendererComponent(header.getTable(),
- val,
- false, // isSelected
- false, // isFocused
- -1, i);
- comp.setFont(header.getFont());
- comp.setBackground(header.getBackground());
- comp.setForeground(header.getForeground());
- if (comp instanceof JComponent)
- ((JComponent)comp).setBorder(cellBorder);
-
- Dimension d = comp.getMaximumSize();
- ret.width += col.getMaxWidth();
- ret.height = Math.max(ret.height, d.height);
- ret.width += spacing;
- }
- return ret;
- }
-
- public Dimension getMinimumSize(JComponent c)
- {
- TableColumnModel cmod = header.getColumnModel();
- TableCellRenderer defaultRend = header.getDefaultRenderer();
- int ncols = cmod.getColumnCount();
- int spacing = 0;
- Dimension ret = getPreferredSize(c);
-
- if (header.getTable() != null
- && header.getTable().getInterCellSpacing() != null)
- spacing = header.getTable().getInterCellSpacing().width;
-
- ret.width = 0;
- for (int i = 0; i < ncols; ++i)
- {
- TableColumn col = cmod.getColumn(i);
- TableCellRenderer rend = col.getHeaderRenderer();
- if (rend == null)
- rend = defaultRend;
- Object val = col.getHeaderValue();
- Component comp = rend.getTableCellRendererComponent(header.getTable(),
- val,
- false, // isSelected
- false, // isFocused
- -1, i);
- comp.setFont(header.getFont());
- comp.setBackground(header.getBackground());
- comp.setForeground(header.getForeground());
- if (comp instanceof JComponent)
- ((JComponent)comp).setBorder(cellBorder);
-
- Dimension d = comp.getMinimumSize();
- ret.width += col.getMinWidth();
- ret.width += spacing;
- ret.height = Math.max(ret.height, d.height);
- }
- return ret;
- }
public Dimension getPreferredSize(JComponent c)
{
@@ -291,10 +213,10 @@ public class BasicTableHeaderUI
((JComponent)comp).setBorder(cellBorder);
Dimension d = comp.getPreferredSize();
- ret.width += d.width;
ret.width += spacing;
ret.height = Math.max(d.height, ret.height);
}
+ ret.width = cmod.getTotalColumnWidth();
return ret;
}
diff --git a/javax/swing/plaf/basic/BasicTextPaneUI.java b/javax/swing/plaf/basic/BasicTextPaneUI.java
new file mode 100644
index 000000000..615c74b2b
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicTextPaneUI.java
@@ -0,0 +1,69 @@
+/* BasicTextPaneUI.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+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.plaf.basic;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.JComponent;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.text.Element;
+import javax.swing.text.PlainView;
+import javax.swing.text.View;
+
+public class BasicTextPaneUI extends BasicTextUI
+{
+ public static ComponentUI createUI(JComponent comp)
+ {
+ return new BasicTextPaneUI();
+ }
+
+ public BasicTextPaneUI()
+ {
+ }
+
+ public View create(Element elem)
+ {
+ return new PlainView(elem);
+ }
+
+ protected String getPropertyPrefix()
+ {
+ return "TextPane";
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index 52d4bcf8e..28fa24c3d 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -45,6 +45,8 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -228,9 +230,20 @@ public abstract class BasicTextUI extends TextUI
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));
}
+ private FocusListener focuslistener = new FocusListener() {
+ public void focusGained(FocusEvent e)
+ {
+ textComponent.repaint();
+ }
+ public void focusLost(FocusEvent e)
+ {
+ textComponent.repaint();
+ }
+ };
+
protected void installListeners()
{
- // Do nothing here.
+ textComponent.addFocusListener(focuslistener);
}
protected String getKeymapName()
@@ -328,7 +341,7 @@ public abstract class BasicTextUI extends TextUI
protected void uninstallListeners()
{
- // Do nothing here.
+ textComponent.removeFocusListener(focuslistener);
}
protected void uninstallKeyboardActions()
@@ -367,7 +380,7 @@ public abstract class BasicTextUI extends TextUI
rootView.paint(g, getVisibleEditorRect());
- if (caret != null)
+ if (caret != null && textComponent.hasFocus())
caret.paint(g);
}
@@ -461,8 +474,17 @@ public abstract class BasicTextUI extends TextUI
protected void modelChanged()
{
+ if (textComponent == null || rootView == null)
+ return;
ViewFactory factory = rootView.getViewFactory();
- Element elem = textComponent.getDocument().getDefaultRootElement();
+ if (factory == null)
+ return;
+ Document doc = textComponent.getDocument();
+ if (doc == null)
+ return;
+ Element elem = doc.getDefaultRootElement();
+ if (elem == null)
+ return;
setView(factory.create(elem));
}
}
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
index 45eee5c12..93e390075 100644
--- a/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -38,11 +38,21 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
import java.awt.Rectangle;
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
import javax.swing.JTree;
import javax.swing.plaf.TreeUI;
+import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeModel;
/**
* A delegate providing the user interface for <code>JTree</code>
@@ -57,6 +67,7 @@ import javax.swing.tree.TreePath;
public class BasicTreeUI
extends TreeUI
{
+
/**
* Determines the geometric extent of the label that is
* drawn for a path.
@@ -191,7 +202,6 @@ public class BasicTreeUI
return true; // FIXME: not implemented
}
-
/**
* Cancels editing a tree cell, discarding any entered value.
* If no editing session is active, nothing happens. The cell
@@ -233,4 +243,157 @@ public class BasicTreeUI
{
return null; // FIXME: not implemented
}
+
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicTreeUI();
+ }
+
+ int rightChildIndent;
+ int leftChildIndent;
+ int rowHeight;
+ Color hashColor;
+
+ protected void installDefaults(JTree tree)
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ tree.setFont(defaults.getFont("Tree.font"));
+ tree.setForeground(defaults.getColor("Tree.foreground"));
+ tree.setBackground(defaults.getColor("Tree.background"));
+ tree.setOpaque(true);
+
+ hashColor = defaults.getColor("Tree.hash");
+ rightChildIndent = defaults.getInt("Tree.rightChildIndent");
+ leftChildIndent = defaults.getInt("Tree.leftChildIndent");
+ rowHeight = defaults.getInt("Tree.rowHeight");
+ }
+
+ protected void installKeyboardActions()
+ {
+ }
+
+ protected void installListeners()
+ {
+ }
+
+ public void installUI(JComponent c)
+ {
+ installDefaults((JTree) c);
+ }
+
+
+ protected void uninstallDefaults(JTree tree)
+ {
+ tree.setFont(null);
+ tree.setForeground(null);
+ tree.setBackground(null);
+
+ tree.setCellRenderer(null);
+ }
+
+ public void uninstallUI(JComponent c)
+ {
+ uninstallDefaults((JTree) c);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ return new Dimension(200,200);
+ }
+
+ protected void paintLeaf(Graphics g, int x, int y, JTree tree, Object leaf)
+ {
+ Component c = tree.getCellRenderer().getTreeCellRendererComponent(tree,
+ leaf,
+ false, // selected
+ false, // expanded
+ true, // leaf
+ 0, // row
+ false // hasFocus
+ );
+ g.translate(x, y);
+ c.paint(g);
+ g.translate(-x, -y);
+ }
+
+ protected void paintNonLeaf(Graphics g, int x, int y, JTree tree, Object nonLeaf)
+ {
+ Component c = tree.getCellRenderer().getTreeCellRendererComponent(tree,
+ nonLeaf,
+ false, // selected
+ false, // expanded
+ false, // leaf
+ 0, // row
+ false // hasFocus
+ );
+ g.translate(x, y);
+ c.paint(g);
+ g.translate(-x, -y);
+ }
+
+ protected int paintRecursive(Graphics g,
+ int indentation,
+ int descent,
+ int childNumber,
+ int depth,
+ JTree tree,
+ TreeModel mod,
+ Object curr)
+ {
+ Rectangle clip = g.getClipBounds();
+ if (indentation > clip.x + clip.width + rightChildIndent ||
+ descent > clip.y + clip.height + rowHeight)
+ return descent;
+
+
+ int halfHeight = rowHeight / 2;
+ int halfWidth = rightChildIndent / 2;
+ int y0 = descent + halfHeight;
+
+ if (mod.isLeaf(curr))
+ {
+ paintLeaf(g, indentation, descent, tree, curr);
+ descent += rowHeight;
+ }
+ else
+ {
+ if (depth > 0 || tree.isRootVisible())
+ {
+ paintNonLeaf(g, indentation, descent, tree, curr);
+ descent += rowHeight;
+ y0 += halfHeight;
+ }
+ int max = mod.getChildCount(curr);
+ for (int i = 0; i < max; ++i)
+ {
+ g.setColor(hashColor);
+ g.drawLine(indentation + halfWidth, descent + halfHeight,
+ indentation + rightChildIndent, descent + halfHeight);
+ descent = paintRecursive(g,
+ indentation + rightChildIndent, descent,
+ i, depth+1,
+ tree, mod, mod.getChild(curr, i));
+ }
+ }
+
+ int y1 = descent - halfHeight;
+ if (y0 != y1)
+ {
+ g.setColor(hashColor);
+ g.drawLine(indentation + halfWidth, y0,
+ indentation + halfWidth, y1);
+ }
+
+ return descent;
+ }
+
+ public void paint(Graphics g, JComponent c)
+ {
+ JTree tree = (JTree) c;
+ TreeModel mod = tree.getModel();
+ g.translate(10, 10);
+ paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());
+ g.translate(-10, -10);
+ }
}
diff --git a/javax/swing/plaf/basic/BasicViewportUI.java b/javax/swing/plaf/basic/BasicViewportUI.java
index 46113e34f..1e0421b02 100644
--- a/javax/swing/plaf/basic/BasicViewportUI.java
+++ b/javax/swing/plaf/basic/BasicViewportUI.java
@@ -120,17 +120,16 @@ public class BasicViewportUI extends ViewportUI
}
public void paint(Graphics g, JComponent c)
- {
-
- JViewport v = (JViewport)c;
- Component view = v.getView();
+ {
+ JViewport port = (JViewport)c;
+ Component view = port.getView();
if (view == null)
return;
- Point pos = v.getViewPosition();
+ Point pos = port.getViewPosition();
Rectangle viewBounds = view.getBounds();
- Rectangle portBounds = v.getBounds();
+ Rectangle portBounds = port.getBounds();
if (viewBounds.width == 0
|| viewBounds.height == 0
@@ -138,6 +137,51 @@ public class BasicViewportUI extends ViewportUI
|| portBounds.height == 0)
return;
+ switch (port.getScrollMode())
+ {
+
+ case JViewport.BACKINGSTORE_SCROLL_MODE:
+ paintBackingStore(g, port, view, pos, viewBounds, portBounds);
+ break;
+
+ case JViewport.BLIT_SCROLL_MODE:
+ // FIXME: implement separate blit mode
+
+ case JViewport.SIMPLE_SCROLL_MODE:
+ default:
+ paintSimple(g, port, view, pos, viewBounds, portBounds);
+ break;
+ }
+ }
+
+ private void paintSimple(Graphics g,
+ JViewport v,
+ Component view,
+ Point pos,
+ Rectangle viewBounds,
+ Rectangle portBounds)
+ {
+ Rectangle oldClip = g.getClipBounds ();
+ g.setClip (oldClip.intersection (viewBounds));
+ g.translate (-pos.x, -pos.y);
+ try
+ {
+ view.paint(g);
+ }
+ finally
+ {
+ g.translate (pos.x, pos.y);
+ g.setClip (oldClip);
+ }
+ }
+
+ private void paintBackingStore(Graphics g,
+ JViewport v,
+ Component view,
+ Point pos,
+ Rectangle viewBounds,
+ Rectangle portBounds)
+ {
if (backingStoreImage == null
|| backingStoreWidth != viewBounds.width
|| backingStoreHeight != viewBounds.height)
@@ -149,18 +193,17 @@ public class BasicViewportUI extends ViewportUI
Graphics g2 = backingStoreImage.getGraphics();
-
- if (c.getBackground() != null)
+ if (v.getBackground() != null)
{
// fill the backing store background
java.awt.Color save = g2.getColor();
- g2.setColor(c.getBackground());
+ g2.setColor(v.getBackground());
g2.fillRect (0, 0, backingStoreWidth, backingStoreHeight);
g2.setColor(save);
// fill the viewport background
save = g.getColor();
- g.setColor(c.getBackground());
+ g.setColor(v.getBackground());
g.fillRect (0, 0, portBounds.width, portBounds.height);
g.setColor(save);
diff --git a/javax/swing/text/FieldView.java b/javax/swing/text/FieldView.java
index 06514b73f..3f1de3772 100644
--- a/javax/swing/text/FieldView.java
+++ b/javax/swing/text/FieldView.java
@@ -43,7 +43,6 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Shape;
-
public class FieldView extends PlainView
{
public FieldView(Element elem)
@@ -79,7 +78,6 @@ public class FieldView extends PlainView
{
// This should never happen.
text = "";
- System.out.println("Michael: FieldView.getPreferredSpan: Error");
}
return fm.stringWidth(text);
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
index 934468268..582612872 100644
--- a/javax/swing/text/GapContent.java
+++ b/javax/swing/text/GapContent.java
@@ -93,7 +93,7 @@ public class GapContent
public String getString(int where, int len) throws BadLocationException
{
- return buf.toString();
+ return buf.substring(where, where+len);
}
public void getChars(int where, int len, Segment txt)
diff --git a/javax/swing/text/JTextComponent.java b/javax/swing/text/JTextComponent.java
index 45401c1f7..0bca84b0f 100644
--- a/javax/swing/text/JTextComponent.java
+++ b/javax/swing/text/JTextComponent.java
@@ -1015,12 +1015,16 @@ public abstract class JTextComponent extends JComponent
/**
* Enables/disabled this text component's editability.
*
- * @param editable true to make it editable, false otherwise.
+ * @param newValue true to make it editable, false otherwise.
*/
- public void setEditable(boolean editable)
+ public void setEditable(boolean newValue)
{
- firePropertyChange("editable", this.editable, editable);
- this.editable = editable;
+ if (editable == newValue)
+ return;
+
+ boolean oldValue = editable;
+ editable = newValue;
+ firePropertyChange("editable", oldValue, newValue);
}
/**
@@ -1258,7 +1262,6 @@ public abstract class JTextComponent extends JComponent
catch (BadLocationException e)
{
// This should never happen.
- System.out.println("Michael: JTextComponent.replaceSelection: Error");
}
}
diff --git a/javax/swing/text/PlainDocument.java b/javax/swing/text/PlainDocument.java
index 4a8adfca5..22808700a 100644
--- a/javax/swing/text/PlainDocument.java
+++ b/javax/swing/text/PlainDocument.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing.text;
+import java.util.ArrayList;
+
public class PlainDocument extends AbstractDocument
{
private static final long serialVersionUID = 4758290289196893664L;
@@ -59,14 +61,53 @@ public class PlainDocument extends AbstractDocument
rootElement = createDefaultRoot();
}
+ protected void reindex()
+ {
+ Element[] lines;
+ try
+ {
+ String str = content.getString(0, content.length());
+
+ ArrayList elts = new ArrayList();
+ int j = 0;
+ for (int i = str.indexOf('\n', 0); i != -1; i = str.indexOf('\n', i+1))
+ {
+ elts.add(createLeafElement(rootElement, null, j, i));
+ j = i;
+ }
+
+ if (j < content.length())
+ elts.add(createLeafElement(rootElement, null, j, content.length()));
+
+ lines = new Element[elts.size()];
+ for (int i = 0; i < elts.size(); ++i)
+ lines[i] = (Element) elts.get(i);
+
+ }
+ catch (BadLocationException e)
+ {
+ lines = new Element[1];
+ lines[0] = createLeafElement(rootElement, null, 0, 1);
+ }
+
+ ((BranchElement) rootElement).replace(0, rootElement.getElementCount(), lines);
+ }
+
protected AbstractDocument.AbstractElement createDefaultRoot()
{
- BranchElement rootElement =
- (BranchElement) createBranchElement(null, null);
- Element[] lines = new Element[1];
- lines[0] = createLeafElement(rootElement, null, 0, 1);
- rootElement.replace(0, 0, lines);
- return rootElement;
+ rootElement = createBranchElement(null, null);
+ reindex();
+ return (AbstractElement) rootElement;
+ }
+
+ protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr)
+ {
+ reindex();
+ }
+
+ protected void removeUpdate(DefaultDocumentEvent chng)
+ {
+ reindex();
}
public Element getDefaultRootElement()
diff --git a/javax/swing/text/SimpleAttributeSet.java b/javax/swing/text/SimpleAttributeSet.java
index 0ca46fc83..1578a48ab 100644
--- a/javax/swing/text/SimpleAttributeSet.java
+++ b/javax/swing/text/SimpleAttributeSet.java
@@ -57,7 +57,8 @@ public class SimpleAttributeSet
public SimpleAttributeSet(AttributeSet a)
{
tab = new Hashtable();
- addAttributes(a);
+ if (a != null)
+ addAttributes(a);
}
public void addAttribute(Object name, Object value)
diff --git a/javax/swing/text/Utilities.java b/javax/swing/text/Utilities.java
index d954e886e..6d2b54680 100644
--- a/javax/swing/text/Utilities.java
+++ b/javax/swing/text/Utilities.java
@@ -98,15 +98,17 @@ public class Utilities
for (int offset = s.offset; offset < (s.offset + s.count); ++offset)
{
char c = buffer[offset];
- if (len > 0 && (c == '\t' || c == '\n'))
+ if (c == '\t' || c == '\n')
{
- g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);
- pixelX += pixelWidth;
- pixelWidth = 0;
+ if (len > 0) {
+ g.drawChars(buffer, pos, len, pixelX, pixelY + ascent);
+ pixelX += pixelWidth;
+ pixelWidth = 0;
+ }
pos = offset+1;
len = 0;
}
-
+
switch (c)
{
case '\t':
diff --git a/javax/swing/tree/AbstractLayoutCache.java b/javax/swing/tree/AbstractLayoutCache.java
index 5553995ae..6fb75f77f 100644
--- a/javax/swing/tree/AbstractLayoutCache.java
+++ b/javax/swing/tree/AbstractLayoutCache.java
@@ -44,55 +44,39 @@ import java.util.Enumeration;
import javax.swing.event.TreeModelEvent;
/**
- * AbstractLayoutCache
+ * class AbstractLayoutCache
+ *
* @author Andrew Selkirk
*/
public abstract class AbstractLayoutCache implements RowMapper
{
-
- //-------------------------------------------------------------
- // Classes ----------------------------------------------------
- //-------------------------------------------------------------
-
/**
- * NodeDimensions
+ * class NodeDimensions
*/
- public abstract static class NodeDimensions {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
+ public abstract static class NodeDimensions
+ {
/**
- * Constructor NodeDimensions
+ * Creates <code>NodeDimensions</code> object.
*/
- public NodeDimensions() {
- // TODO
- } // NodeDimensions()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
+ public NodeDimensions()
+ {
+ // Do nothing here.
+ }
/**
* getNodeDimensions
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
* @param value3 TODO
* @param value4 TODO
- * @returns Rectangle
+ * @return Rectangle
*/
- public abstract Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4);
-
-
- } // NodeDimensions
-
-
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
+ public abstract Rectangle getNodeDimensions(Object value0, int value1,
+ int value2, boolean value3,
+ Rectangle value4);
+ }
/**
* nodeDimensions
@@ -119,201 +103,241 @@ public abstract class AbstractLayoutCache implements RowMapper
*/
protected int rowHeight;
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
/**
* Constructor AbstractLayoutCache
*/
- public AbstractLayoutCache() {
- // TODO
- } // AbstractLayoutCache()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
+ public AbstractLayoutCache()
+ {
+ // Do nothing here.
+ }
/**
* setNodeDimensions
- * @param value0 TODO
+ *
+ * @param dimensions TODO
*/
- public void setNodeDimensions(NodeDimensions value0) {
- // TODO
- } // setNodeDimensions()
+ public void setNodeDimensions(NodeDimensions dimensions)
+ {
+ nodeDimensions = dimensions;
+ }
/**
* getNodeDimensions
- * @returns NodeDimensions
+ *
+ * @return NodeDimensions
*/
- public NodeDimensions getNodeDimensions() {
- return null; // TODO
- } // getNodeDimensions()
+ public NodeDimensions getNodeDimensions()
+ {
+ return nodeDimensions;
+ }
/**
* getNodeDimensions
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
* @param value3 TODO
* @param value4 TODO
- * @returns Rectangle
+ *
+ * @return Rectangle
*/
- protected Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4) {
+ protected Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4)
+ {
return null; // TODO
- } // getNodeDimensions()
+ }
/**
- * setModel
- * @param value0 TODO
+ * Sets the model that provides the tree data.
+ *
+ * @param the model
*/
- public void setModel(TreeModel value0) {
- // TODO
- } // setModel()
+ public void setModel(TreeModel model)
+ {
+ treeModel = model;
+ }
/**
- * getModel
- * @returns TreeModel
+ * Returns the model that provides the tree data.
+ *
+ * @return the model
*/
- public TreeModel getModel() {
- return null; // TODO
- } // getModel()
+ public TreeModel getModel()
+ {
+ return treeModel;
+ }
/**
* setRootVisible
- * @param value0 TODO
+ *
+ * @param visible <code>true</code> if root should be visible,
+ * <code>false</code> otherwise
*/
- public void setRootVisible(boolean value0) {
- // TODO
- } // setRootVisible()
+ public void setRootVisible(boolean visible)
+ {
+ rootVisible = visible;
+ }
/**
* isRootVisible
- * @returns boolean
+ *
+ * @return <code>true</code> if root is visible,
+ * <code>false</code> otherwise
*/
- public boolean isRootVisible() {
- return false; // TODO
- } // isRootVisible()
+ public boolean isRootVisible()
+ {
+ return rootVisible;
+ }
/**
* setRowHeight
- * @param value0 TODO
+ *
+ * @param height the row height
*/
- public void setRowHeight(int value0) {
- // TODO
- } // setRowHeight()
+ public void setRowHeight(int height)
+ {
+ rowHeight = height;
+ }
/**
* getRowHeight
- * @returns int
+ *
+ * @return the row height
*/
- public int getRowHeight() {
- return 0; // TODO
- } // getRowHeight()
+ public int getRowHeight()
+ {
+ return rowHeight;
+ }
/**
* setSelectionModel
- * @param value0 TODO
+ *
+ * @param model the model
*/
- public void setSelectionModel(TreeSelectionModel value0) {
- // TODO
- } // setSelectionModel()
+ public void setSelectionModel(TreeSelectionModel model)
+ {
+ treeSelectionModel = model;
+ }
/**
* getSelectionModel
- * @returns TreeSelectionModel
+ *
+ * @return the model
*/
- public TreeSelectionModel getSelectionModel() {
- return null; // TODO
- } // getSelectionModel()
+ public TreeSelectionModel getSelectionModel()
+ {
+ return treeSelectionModel;
+ }
/**
* getPreferredHeight
- * @returns int
+ *
+ * @return int
*/
- public int getPreferredHeight() {
+ public int getPreferredHeight()
+ {
return 0; // TODO
- } // getPreferredHeight()
+ }
/**
* getPreferredWidth
+ *
* @param value0 TODO
- * @returns int
+ *
+ * @return int
*/
- public int getPreferredWidth(Rectangle value0) {
+ public int getPreferredWidth(Rectangle value0)
+ {
return 0; // TODO
- } // getPreferredWidth()
+ }
/**
* isExpanded
+ *
* @param value0 TODO
- * @returns boolean
+ *
+ * @return boolean
*/
public abstract boolean isExpanded(TreePath value0);
/**
* getBounds
+ *
* @param value0 TODO
* @param value1 TODO
- * @returns Rectangle
+ *
+ * @return Rectangle
*/
public abstract Rectangle getBounds(TreePath value0, Rectangle value1);
/**
* getPathForRow
- * @param value0 TODO
- * @returns TreePath
+ *
+ * @param row the row
+ *
+ * @return the tree path
*/
- public abstract TreePath getPathForRow(int value0);
+ public abstract TreePath getPathForRow(int row);
/**
* getRowForPath
- * @param value0 TODO
- * @returns int
+ *
+ * @param path the tree path
+ *
+ * @return the row
*/
- public abstract int getRowForPath(TreePath value0);
+ public abstract int getRowForPath(TreePath path);
/**
* getPathClosestTo
+ *
* @param value0 TODO
* @param value1 TODO
- * @returns TreePath
+ *
+ * @return the tree path
*/
public abstract TreePath getPathClosestTo(int value0, int value1);
/**
* getVisiblePathsFrom
- * @param value0 TODO
- * @returns Enumeration
+ *
+ * @param path the tree path
+ *
+ * @return Enumeration
*/
- public abstract Enumeration getVisiblePathsFrom(TreePath value0);
+ public abstract Enumeration getVisiblePathsFrom(TreePath path);
/**
* getVisibleChildCount
- * @param value0 TODO
- * @returns int
+ *
+ * @param path the tree path
+ *
+ * @return int
*/
public abstract int getVisibleChildCount(TreePath value0);
/**
* setExpandedState
+ *
* @param value0 TODO
+ *
* @param value1 TODO
*/
public abstract void setExpandedState(TreePath value0, boolean value1);
/**
* getExpandedState
- * @param value0 TODO
- * @returns boolean
+ *
+ * @param path the tree path
+ *
+ * @return boolean
*/
- public abstract boolean getExpandedState(TreePath value0);
+ public abstract boolean getExpandedState(TreePath path);
/**
* getRowCount
- * @returns int
+ *
+ * @return the number of rows
*/
public abstract int getRowCount();
@@ -324,50 +348,58 @@ public abstract class AbstractLayoutCache implements RowMapper
/**
* invalidatePathBounds
- * @param value0 TODO
+ *
+ * @param path the tree path
*/
- public abstract void invalidatePathBounds(TreePath value0);
+ public abstract void invalidatePathBounds(TreePath path);
/**
* treeNodesChanged
- * @param value0 TODO
+ *
+ * @param event the event to send
*/
- public abstract void treeNodesChanged(TreeModelEvent value0);
+ public abstract void treeNodesChanged(TreeModelEvent event);
/**
* treeNodesInserted
- * @param value0 TODO
+ *
+ * @param event the event to send
*/
- public abstract void treeNodesInserted(TreeModelEvent value0);
+ public abstract void treeNodesInserted(TreeModelEvent event);
/**
* treeNodesRemoved
- * @param value0 TODO
+ *
+ * @param event the event to send
*/
- public abstract void treeNodesRemoved(TreeModelEvent value0);
+ public abstract void treeNodesRemoved(TreeModelEvent event);
/**
* treeStructureChanged
- * @param value0 TODO
+ *
+ * @param event the event to send
*/
- public abstract void treeStructureChanged(TreeModelEvent value0);
+ public abstract void treeStructureChanged(TreeModelEvent event);
/**
* getRowsForPaths
- * @param value0 TODO
- * @returns int[]
+ *
+ * @param paths the tree paths
+ *
+ * @return an array of rows
*/
- public int[] getRowsForPaths(TreePath[] value0) {
+ public int[] getRowsForPaths(TreePath[] paths)
+ {
return null; // TODO
- } // getRowsForPaths()
+ }
/**
* isFixedRowHeight
- * @returns boolean
+ *
+ * @return boolean
*/
- protected boolean isFixedRowHeight() {
+ protected boolean isFixedRowHeight()
+ {
return false; // TODO
- } // isFixedRowHeight()
-
-
-} // AbstractLayoutCache
+ }
+}
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index 863b9f8e7..beae3840b 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -48,6 +48,9 @@ import java.awt.Rectangle;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JTree;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.UIResource;
/**
* DefaultTreeCellRenderer
@@ -125,8 +128,18 @@ public class DefaultTreeCellRenderer
* Constructor DefaultTreeCellRenderer
*/
public DefaultTreeCellRenderer() {
- // TODO
- } // DefaultTreeCellRenderer()
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ setLeafIcon(getDefaultLeafIcon());
+ setOpenIcon(getDefaultOpenIcon());
+ setClosedIcon(getDefaultClosedIcon());
+
+ setTextNonSelectionColor(defaults.getColor("Tree.textForeground"));
+ setTextSelectionColor(defaults.getColor("Tree.selectionForeground"));
+ setBackgroundNonSelectionColor(defaults.getColor("Tree.textBackground"));
+ setBackgroundSelectionColor(defaults.getColor("Tree.selectionBackground"));
+ setBorderSelectionColor(defaults.getColor("Tree.selectionBorderColor"));
+ }
//-------------------------------------------------------------
@@ -138,168 +151,172 @@ public class DefaultTreeCellRenderer
* @returns Icon
*/
public Icon getDefaultOpenIcon() {
- return null; // TODO
- } // getDefaultOpenIcon()
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon");
+ }
/**
* getDefaultClosedIcon
* @returns Icon
*/
public Icon getDefaultClosedIcon() {
- return null; // TODO
- } // getDefaultClosedIcon()
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
+ }
/**
* getDefaultLeafIcon
* @returns Icon
*/
public Icon getDefaultLeafIcon() {
- return null; // TODO
- } // getDefaultLeafIcon()
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
+ }
/**
* setOpenIcon
* @param value0 TODO
*/
- public void setOpenIcon(Icon value0) {
- // TODO
- } // setOpenIcon()
+ public void setOpenIcon(Icon i) {
+ openIcon = i;
+ }
/**
* getOpenIcon
* @returns Icon
*/
public Icon getOpenIcon() {
- return null; // TODO
- } // getOpenIcon()
+ return openIcon;
+ }
/**
* setClosedIcon
* @param value0 TODO
*/
- public void setClosedIcon(Icon value0) {
- // TODO
- } // setClosedIcon()
+ public void setClosedIcon(Icon i) {
+ closedIcon = i;
+ }
/**
* getClosedIcon
* @returns Icon
*/
public Icon getClosedIcon() {
- return null; // TODO
- } // getClosedIcon()
+ return closedIcon;
+ }
/**
* setLeafIcon
* @param value0 TODO
*/
- public void setLeafIcon(Icon value0) {
- // TODO
- } // setLeafIcon()
+ public void setLeafIcon(Icon i) {
+ leafIcon = i;
+ }
/**
* getLeafIcon
* @returns Icon
*/
public Icon getLeafIcon() {
- return null; // TODO
- } // getLeafIcon()
+ return leafIcon;
+ }
/**
* setTextSelectionColor
* @param value0 TODO
*/
- public void setTextSelectionColor(Color value0) {
- // TODO
- } // setTextSelectionColor()
+ public void setTextSelectionColor(Color c) {
+ textSelectionColor = c;
+ }
/**
* getTextSelectionColor
* @returns Color
*/
public Color getTextSelectionColor() {
- return null; // TODO
- } // getTextSelectionColor()
+ return textSelectionColor;
+ }
/**
* setTextNonSelectionColor
* @param value0 TODO
*/
- public void setTextNonSelectionColor(Color value0) {
- // TODO
- } // setTextNonSelectionColor()
+ public void setTextNonSelectionColor(Color c) {
+ textNonSelectionColor = c;
+ }
/**
* getTextNonSelectionColor
* @returns Color
*/
public Color getTextNonSelectionColor() {
- return null; // TODO
- } // getTextNonSelectionColor()
+ return textNonSelectionColor;
+ }
/**
* setBackgroundSelectionColor
* @param value0 TODO
*/
- public void setBackgroundSelectionColor(Color value0) {
- // TODO
- } // setBackgroundSelectionColor()
+ public void setBackgroundSelectionColor(Color c) {
+ backgroundSelectionColor = c;
+ }
/**
* getBackgroundSelectionColor
* @returns Color
*/
public Color getBackgroundSelectionColor() {
- return null; // TODO
- } // getBackgroundSelectionColor()
+ return backgroundSelectionColor;
+ }
/**
* setBackgroundNonSelectionColor
* @param value0 TODO
*/
- public void setBackgroundNonSelectionColor(Color value0) {
- // TODO
- } // setBackgroundNonSelectionColor()
+ public void setBackgroundNonSelectionColor(Color c) {
+ backgroundNonSelectionColor = c;
+ }
/**
* getBackgroundNonSelectionColor
* @returns Color
*/
public Color getBackgroundNonSelectionColor() {
- return null; // TODO
- } // getBackgroundNonSelectionColor()
+ return backgroundNonSelectionColor;
+ }
/**
* setBorderSelectionColor
* @param value0 TODO
*/
- public void setBorderSelectionColor(Color value0) {
- // TODO
- } // setBorderSelectionColor()
+ public void setBorderSelectionColor(Color c) {
+ borderSelectionColor = c;
+ }
/**
* getBorderSelectionColor
* @returns Color
*/
public Color getBorderSelectionColor() {
- return null; // TODO
- } // getBorderSelectionColor()
+ return borderSelectionColor;
+ }
/**
* setFont
* @param value0 TODO
*/
- public void setFont(Font value0) {
- // TODO
- } // setFont()
+ public void setFont(Font f) {
+ if (f != null && f instanceof UIResource)
+ f = null;
+ super.setFont(f);
+ }
/**
* setBackground
* @param value0 TODO
*/
- public void setBackground(Color value0) {
- // TODO
- } // setBackground()
+ public void setBackground(Color c) {
+ if (c != null && c instanceof UIResource)
+ c = null;
+ super.setBackground(c);
+ }
/**
* getTreeCellRendererComponent
@@ -312,17 +329,37 @@ public class DefaultTreeCellRenderer
* @param value6 TODO
* @returns Component
*/
- public Component getTreeCellRendererComponent(JTree value0, Object value1, boolean value2, boolean value3, boolean value4, int value5, boolean value6) {
- return null; // TODO
- } // getTreeCellRendererComponent()
+ public Component getTreeCellRendererComponent(JTree tree,
+ Object val,
+ boolean selected,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus) {
+ this.selected = selected;
+ this.hasFocus = hasFocus;
+
+ if (leaf)
+ setIcon(getLeafIcon());
+ else if (expanded)
+ setIcon(getOpenIcon());
+ else
+ setIcon(getClosedIcon());
+
+ setText(val.toString());
+ setHorizontalAlignment(LEFT);
+ setVerticalAlignment(TOP);
+
+ return this;
+ }
/**
* paint
* @param value0 TODO
*/
- public void paint(Graphics value0) {
- // TODO
- } // paint()
+ public void paint(Graphics g) {
+ super.paint(g);
+ }
/**
* getPreferredSize
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index d2a879af7..2e34a3522 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -175,9 +175,12 @@ public class DefaultTreeModel
* @param value1 TODO
* @return Object
*/
- public Object getChild(Object value0, int value1)
+ public Object getChild(Object node, int idx)
{
- return null; // TODO
+ if (node instanceof TreeNode)
+ return ((TreeNode)node).getChildAt(idx);
+ else
+ return null;
}
/**
@@ -185,9 +188,12 @@ public class DefaultTreeModel
* @param value0 TODO
* @return int
*/
- public int getChildCount(Object value0)
+ public int getChildCount(Object node)
{
- return 0; // TODO
+ if (node instanceof TreeNode)
+ return ((TreeNode)node).getChildCount();
+ else
+ return 0;
}
/**
@@ -195,9 +201,12 @@ public class DefaultTreeModel
* @param value0 TODO
* @return boolean
*/
- public boolean isLeaf(Object value0)
+ public boolean isLeaf(Object node)
{
- return false; // TODO
+ if (node instanceof TreeNode)
+ return ((TreeNode)node).isLeaf();
+ else
+ return true;
}
/**