summaryrefslogtreecommitdiff
path: root/javax
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-11-02 21:44:44 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-11-02 21:44:44 +0000
commit097fee26e85fdf21417a5d67d4a99d26e1e61a09 (patch)
tree6a85b8574af60d2dd13ae320278e45114a9d204c /javax
parent9c9bd939533e1710923a604d1cc4207ff7032668 (diff)
downloadclasspath-097fee26e85fdf21417a5d67d4a99d26e1e61a09.tar.gz
2005-11-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge from HEAD --> generics for 2005/11/01-2005/11/02.
Diffstat (limited to 'javax')
-rw-r--r--javax/swing/BoxLayout.java14
-rw-r--r--javax/swing/JComponent.java179
-rw-r--r--javax/swing/JTable.java446
-rw-r--r--javax/swing/JToolBar.java1
-rw-r--r--javax/swing/filechooser/FileSystemView.java152
-rw-r--r--javax/swing/filechooser/UnixFileSystemView.java47
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java8
-rw-r--r--javax/swing/plaf/basic/BasicScrollPaneUI.java23
-rw-r--r--javax/swing/plaf/basic/BasicToolBarUI.java1
-rw-r--r--javax/swing/plaf/metal/MetalScrollPaneUI.java9
-rw-r--r--javax/swing/text/WrappedPlainView.java3
11 files changed, 774 insertions, 109 deletions
diff --git a/javax/swing/BoxLayout.java b/javax/swing/BoxLayout.java
index fb540e478..ebc0b4c21 100644
--- a/javax/swing/BoxLayout.java
+++ b/javax/swing/BoxLayout.java
@@ -141,6 +141,9 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public BoxLayout(Container container, int way)
{
+ if (way != X_AXIS && way != Y_AXIS && way != LINE_AXIS && way != PAGE_AXIS)
+ throw new AWTError("Invalid axis");
+
int width = 0;
int height = 0;
this.container = container;
@@ -216,7 +219,9 @@ public class BoxLayout implements LayoutManager2, Serializable
throw new AWTError("BoxLayout can't be shared");
checkTotalRequirements();
- return new Dimension(xTotal.minimum, yTotal.minimum);
+ Insets i = container.getInsets();
+ return new Dimension(xTotal.minimum + i.left + i.right,
+ yTotal.minimum + i.top + i.bottom);
}
}
@@ -297,6 +302,9 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void invalidateLayout(Container parent)
{
+ if (container != parent)
+ throw new AWTError("BoxLayout can't be shared");
+
synchronized (container.getTreeLock())
{
xChildren = null;
@@ -326,7 +334,9 @@ public class BoxLayout implements LayoutManager2, Serializable
throw new AWTError("BoxLayout can't be shared");
checkTotalRequirements();
- return new Dimension(xTotal.maximum, yTotal.maximum);
+ Insets i = container.getInsets();
+ return new Dimension(xTotal.maximum + i.left + i.right,
+ yTotal.maximum + i.top + i.bottom);
}
}
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 80cfc5b32..a800501d7 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -84,6 +84,8 @@ import javax.accessibility.AccessibleKeyBinding;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
import javax.swing.border.Border;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.TitledBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.event.EventListenerList;
@@ -161,9 +163,14 @@ public abstract class JComponent extends Container implements Serializable
protected ContainerListener accessibleContainerHandler;
protected FocusListener accessibleFocusHandler;
+ /**
+ * Manages the property change listeners;
+ */
+ private SwingPropertyChangeSupport changeSupport;
+
protected AccessibleJComponent()
{
- // TODO: Implement this properly.
+ changeSupport = new SwingPropertyChangeSupport(this);
}
/**
@@ -173,16 +180,58 @@ public abstract class JComponent extends Container implements Serializable
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
{
- // TODO: Why is this overridden?
- super.addPropertyChangeListener(listener);
+ changeSupport.addPropertyChangeListener(listener);
}
+ /**
+ * Removes a propery change listener from the list of registered listeners.
+ *
+ * @param listener the listener to remove
+ */
public void removePropertyChangeListener(PropertyChangeListener listener)
{
- // TODO: Implement this properly.
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Returns the number of accessible children of this object.
+ *
+ * @return the number of accessible children of this object
+ */
+ public int getAccessibleChildrenCount()
+ {
+ int count = 0;
+ Component[] children = getComponents();
+ for (int i = 0; i < children.length; ++i)
+ {
+ if (children[i] instanceof Accessible)
+ count++;
+ }
+ return count;
+ }
+
+ /**
+ * Returns the accessible child component at index <code>i</code>.
+ *
+ * @param i the index of the accessible child to return
+ *
+ * @return the accessible child component at index <code>i</code>
+ */
+ public Accessible getAccessibleChild(int i)
+ {
+ int index = 0;
+ Component[] children = getComponents();
+ Accessible found = null;
+ for (int j = 0; index != i; j++)
+ {
+ if (children[j] instanceof Accessible)
+ index++;
+ if (index == i)
+ found = (Accessible) children[index];
+ }
+ // TODO: Figure out what to do when i is not a valid index.
+ return found;
}
- public int getAccessibleChildrenCount() { return 0; }
- public Accessible getAccessibleChild(int value0) { return null; }
/**
* Returns the accessible state set of this component.
@@ -196,13 +245,115 @@ public abstract class JComponent extends Container implements Serializable
return super.getAccessibleStateSet();
}
- public String getAccessibleName() { return null; }
- public String getAccessibleDescription() { return null; }
- public AccessibleRole getAccessibleRole() { return null; }
- protected String getBorderTitle(Border value0) { return null; }
- public String getToolTipText() { return null; }
- public String getTitledBorderText() { return null; }
- public AccessibleKeyBinding getAccessibleKeyBinding() { return null; }
+ /**
+ * Returns the localized name for this object. Generally this should
+ * almost never return {@link Component#getName()} since that is not
+ * a localized name. If the object is some kind of text component (like
+ * a menu item), then the value of the object may be returned. Also, if
+ * the object has a tooltip, the value of the tooltip may also be
+ * appropriate.
+ *
+ * @return the localized name for this object or <code>null</code> if this
+ * object has no name
+ */
+ public String getAccessibleName()
+ {
+ // TODO: Figure out what exactly to return here. It's possible that this
+ // method simply should return null.
+ return null;
+ }
+
+ /**
+ * Returns the localized description of this object.
+ *
+ * @return the localized description of this object or <code>null</code>
+ * if this object has no description
+ */
+ public String getAccessibleDescription()
+ {
+ // TODO: Figure out what exactly to return here. It's possible that this
+ // method simply should return null.
+ return null;
+ }
+
+ /**
+ * Returns the accessible role of this component.
+ *
+ * @return the accessible role of this component
+ *
+ * @see AccessibleRole
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ // TODO: Check if this is correct.
+ return AccessibleRole.SWING_COMPONENT;
+ }
+
+ /**
+ * Recursivly searches a border hierarchy (starting at <code>border) for
+ * a titled border and returns the title if one is found, <code>null</code>
+ * otherwise.
+ *
+ * @param border the border to start search from
+ *
+ * @return the border title of a possibly found titled border
+ */
+ protected String getBorderTitle(Border border)
+ {
+ String title = null;
+ if (border instanceof CompoundBorder)
+ {
+ CompoundBorder compound = (CompoundBorder) border;
+ Border inner = compound.getInsideBorder();
+ title = getBorderTitle(inner);
+ if (title == null)
+ {
+ Border outer = compound.getOutsideBorder();
+ title = getBorderTitle(outer);
+ }
+ }
+ else if (border instanceof TitledBorder)
+ {
+ TitledBorder titled = (TitledBorder) border;
+ title = titled.getTitle();
+ }
+ return title;
+ }
+
+ /**
+ * Returns the tooltip text for this accessible component.
+ *
+ * @return the tooltip text for this accessible component
+ */
+ public String getToolTipText()
+ {
+ return JComponent.this.getToolTipText();
+ }
+
+ /**
+ * Returns the title of the border of this accessible component if
+ * this component has a titled border, otherwise returns <code>null</code>.
+ *
+ * @return the title of the border of this accessible component if
+ * this component has a titled border, otherwise returns
+ * <code>null</code>
+ */
+ public String getTitledBorderText()
+ {
+ return getBorderTitle(getBorder());
+ }
+
+ /**
+ * Returns the keybindings associated with this accessible component or
+ * <code>null</code> if the component does not support key bindings.
+ *
+ * @return the keybindings associated with this accessible component
+ */
+ public AccessibleKeyBinding getAccessibleKeyBinding()
+ {
+ // TODO: Implement this properly.
+ return null;
+ }
}
/**
@@ -3031,7 +3182,7 @@ public abstract class JComponent extends Container implements Serializable
Rectangle currentClip = clip;
Component found = this;
Container parent = this;
- while (parent != null)
+ while (parent != null && !(parent instanceof Window))
{
Container newParent = parent.getParent();
if (newParent == null)
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index 39673b19c..a386559b0 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -40,11 +40,15 @@ package javax.swing;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Cursor;
import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.FocusListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
@@ -52,12 +56,16 @@ import java.text.NumberFormat;
import java.util.Date;
import java.util.EventObject;
import java.util.Hashtable;
+import java.util.Locale;
import java.util.Vector;
import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleExtendedTable;
+import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleStateSet;
import javax.accessibility.AccessibleTable;
import javax.accessibility.AccessibleTableModelChange;
import javax.swing.event.CellEditorListener;
@@ -97,6 +105,444 @@ public class JTable
AccessibleExtendedTable
{
+ /**
+ * Provides accessibility support for table cells.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ protected class AccessibleJTableCell
+ extends AccessibleContext
+ implements Accessible, AccessibleComponent
+ {
+
+ /**
+ * The table of this cell.
+ */
+ private JTable table;
+
+ /**
+ * The row index of this cell.
+ */
+ private int row;
+
+ /**
+ * The column index of this cell.
+ */
+ private int column;
+
+ /**
+ * The index of this cell inside the AccessibleJTable parent.
+ */
+ private int index;
+
+ /**
+ * Creates a new <code>AccessibleJTableCell</code>.
+ *
+ * @param t the table
+ * @param r the row
+ * @param c the column
+ * @param i the index of this cell inside the accessible table parent
+ */
+ public AccessibleJTableCell(JTable t, int r, int c, int i)
+ {
+ table = t;
+ row = r;
+ column = c;
+ index = i;
+ }
+
+ /**
+ * Returns the accessible row for the table cell.
+ *
+ * @return the accessible row for the table cell
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ // TODO: What is the role of the table cell?
+ return AccessibleRole.UNKNOWN;
+ }
+
+ /**
+ * Returns the accessible state set of this accessible table cell.
+ *
+ * @return the accessible state set of this accessible table cell
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ // TODO: What state shoiuld be returned here?
+ return new AccessibleStateSet();
+ }
+
+ /**
+ * Returns the index of this cell in the parent object.
+ *
+ * @return the index of this cell in the parent object
+ */
+ public int getAccessibleIndexInParent()
+ {
+ return index;
+ }
+
+ /**
+ * Returns the number of children of this object. Table cells cannot have
+ * children, so we return <code>0</code> here.
+ *
+ * @return <code>0</code>
+ */
+ public int getAccessibleChildrenCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the accessible child at index <code>i</code>. Table cells
+ * don't have children, so we return <code>null</code> here.
+ *
+ * @return <code>null</code>
+ */
+ public Accessible getAccessibleChild(int i)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the locale setting for this accessible table cell.
+ *
+ * @return the locale setting for this accessible table cell
+ */
+ public Locale getLocale()
+ {
+ // TODO: For now, we return english here. This must be fixed as soon
+ // as we have a localized Swing.
+ return Locale.ENGLISH;
+ }
+
+ /**
+ * Returns the accessible context of this table cell. Since accessible
+ * table cells are their own accessible context, we return
+ * <code>this</code>.
+ *
+ * @return the accessible context of this table cell
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the background color of this cell.
+ *
+ * @return the background color of this cell
+ */
+ public Color getBackground()
+ {
+ return table.getBackground();
+ }
+
+ /**
+ * Sets the background of the cell. Since table cells cannot have
+ * individual background colors, this method does nothing. Set the
+ * background directly on the table instead.
+ *
+ * @param color not used
+ */
+ public void setBackground(Color color)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns the foreground color of the table cell.
+ *
+ * @return the foreground color of the table cell
+ */
+ public Color getForeground()
+ {
+ return table.getForeground();
+ }
+
+ /**
+ * Sets the foreground of the cell. Since table cells cannot have
+ * individual foreground colors, this method does nothing. Set the
+ * foreground directly on the table instead.
+ *
+ * @param color not used
+ */
+ public void setForeground(Color color)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns the cursor for this table cell.
+ *
+ * @return the cursor for this table cell
+ */
+ public Cursor getCursor()
+ {
+ return table.getCursor();
+ }
+
+ /**
+ * Sets the cursor of the cell. Since table cells cannot have
+ * individual cursors, this method does nothing. Set the
+ * cursor directly on the table instead.
+ *
+ * @param cursor not used
+ */
+ public void setCursor(Cursor cursor)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns the font of the table cell.
+ *
+ * @return the font of the table cell
+ */
+ public Font getFont()
+ {
+ return table.getFont();
+ }
+
+ /**
+ * Sets the font of the cell. Since table cells cannot have
+ * individual fonts, this method does nothing. Set the
+ * font directly on the table instead.
+ *
+ * @param font not used
+ */
+ public void setFont(Font font)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns the font metrics for a specified font.
+ *
+ * @param font the font for which we return the metrics
+ *
+ * @return the font metrics for a specified font
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return table.getFontMetrics(font);
+ }
+
+ /**
+ * Returns <code>true</code> if this table cell is enabled,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if this table cell is enabled,
+ * <code>false</code> otherwise
+ */
+ public boolean isEnabled()
+ {
+ return table.isEnabled();
+ }
+
+ /**
+ * Table cells cannot be disabled or enabled individually, so this method
+ * does nothing. Set the enabled flag on the table itself.
+ *
+ * @param b not used here
+ */
+ public void setEnabled(boolean b)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns <code>true</code> if this cell is visible, <code>false</code>
+ * otherwise.
+ *
+ * @return <code>true</code> if this cell is visible, <code>false</code>
+ * otherwise
+ */
+ public boolean isVisible()
+ {
+ return table.isVisible();
+ }
+
+ /**
+ * The visibility cannot be set on individual table cells, so this method
+ * does nothing. Set the visibility on the table itself.
+ *
+ * @param b not used
+ */
+ public void setVisible(boolean b)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns <code>true</code> if this table cell is currently showing on
+ * screen.
+ *
+ * @return <code>true</code> if this table cell is currently showing on
+ * screen
+ */
+ public boolean isShowing()
+ {
+ return table.isShowing();
+ }
+
+ /**
+ * Returns <code>true</code> if this table cell contains the location
+ * at <code>point</code>, <code>false</code> otherwise.
+ * <code>point</code> is interpreted as relative to the coordinate system
+ * of the table cell.
+ *
+ * @return <code>true</code> if this table cell contains the location
+ * at <code>point</code>, <code>false</code> otherwise
+ */
+ public boolean contains(Point point)
+ {
+ Rectangle cellRect = table.getCellRect(row, column, true);
+ cellRect.x = 0;
+ cellRect.y = 0;
+ return cellRect.contains(point);
+ }
+
+ /**
+ * Returns the screen location of the table cell.
+ *
+ * @return the screen location of the table cell
+ */
+ public Point getLocationOnScreen()
+ {
+ Point tableLoc = table.getLocationOnScreen();
+ Rectangle cellRect = table.getCellRect(row, column, true);
+ tableLoc.x += cellRect.x;
+ tableLoc.y += cellRect.y;
+ return tableLoc;
+ }
+
+ /**
+ * Returns the location of this cell relative to the table's bounds.
+ *
+ * @return the location of this cell relative to the table's bounds
+ */
+ public Point getLocation()
+ {
+ Rectangle cellRect = table.getCellRect(row, column, true);
+ return new Point(cellRect.x, cellRect.y);
+ }
+
+ /**
+ * The location of the table cells cannot be manipulated directly, so
+ * this method does nothing.
+ *
+ * @param point not used
+ */
+ public void setLocation(Point point)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns the bounds of the cell relative to its table.
+ *
+ * @return the bounds of the cell relative to its table
+ */
+ public Rectangle getBounds()
+ {
+ return table.getCellRect(row, column, true);
+ }
+
+ /**
+ * The bounds of the table cells cannot be manipulated directly, so
+ * this method does nothing.
+ *
+ * @param rectangle not used
+ */
+ public void setBounds(Rectangle rectangle)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Returns the size of the table cell.
+ *
+ * @return the size of the table cell
+ */
+ public Dimension getSize()
+ {
+ Rectangle cellRect = table.getCellRect(row, column, true);
+ return new Dimension(cellRect.width, cellRect.height);
+ }
+
+ /**
+ * The size cannot be set on table cells directly, so this method does
+ * nothing.
+ *
+ * @param dimension not used
+ */
+ public void setSize(Dimension dimension)
+ {
+ // This method does nothing. See API comments.
+ }
+
+ /**
+ * Table cells have no children, so we return <code>null</code> here.
+ *
+ * @return <code>null</code>
+ */
+ public Accessible getAccessibleAt(Point point)
+ {
+ return null;
+ }
+
+ /**
+ * Returns <code>true</code> if this table cell is focus traversable,
+ * <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if this table cell is focus traversable,
+ * <code>false</code> otherwise
+ */
+ public boolean isFocusTraversable()
+ {
+ return table.isFocusable();
+ }
+
+ /**
+ * Requests that this table cell gets the keyboard focus.
+ */
+ public void requestFocus()
+ {
+ // We first set the selection models' lead selection to this cell.
+ table.getColumnModel().getSelectionModel()
+ .setLeadSelectionIndex(column);
+ table.getSelectionModel().setLeadSelectionIndex(row);
+ // Now we request that the table receives focus.
+ table.requestFocus();
+ }
+
+ /**
+ * Adds a focus listener to this cell. The focus listener is really
+ * added to the table, so there is no way to find out when an individual
+ * cell changes the focus.
+ *
+ * @param listener the focus listener to add
+ */
+ public void addFocusListener(FocusListener listener)
+ {
+ table.addFocusListener(listener);
+ }
+
+ /**
+ * Removes a focus listener from the cell. The focus listener is really
+ * removed from the table.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeFocusListener(FocusListener listener)
+ {
+ table.removeFocusListener(listener);
+ }
+
+ }
+
protected class AccessibleJTableModelChange
implements AccessibleTableModelChange
{
diff --git a/javax/swing/JToolBar.java b/javax/swing/JToolBar.java
index dc85e294d..a508ee6d8 100644
--- a/javax/swing/JToolBar.java
+++ b/javax/swing/JToolBar.java
@@ -752,7 +752,6 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible
{
AbstractButton b = (AbstractButton) component;
b.setRolloverEnabled(rollover);
- b.updateUI();
}
} // addImpl()
diff --git a/javax/swing/filechooser/FileSystemView.java b/javax/swing/filechooser/FileSystemView.java
index 5867cdbe3..f51b745c8 100644
--- a/javax/swing/filechooser/FileSystemView.java
+++ b/javax/swing/filechooser/FileSystemView.java
@@ -40,11 +40,14 @@ package javax.swing.filechooser;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+
import javax.swing.Icon;
+import javax.swing.JFileChooser;
/**
- * DOCUMENT ME!
+ * The base class providing a view of the file system for use by the
+ * {@link JFileChooser} component.
*/
public abstract class FileSystemView
{
@@ -52,12 +55,12 @@ public abstract class FileSystemView
private static FileSystemView defaultFileSystemView;
/**
- * DOCUMENT ME!
+ * Creates a new file object with the given name in the specified directory.
*
- * @param dir DOCUMENT ME!
- * @param filename DOCUMENT ME!
+ * @param dir the directory (<code>null</code> permitted).
+ * @param filename the file name.
*
- * @return DOCUMENT ME!
+ * @return A new file object.
*/
public File createFileObject(File dir, String filename)
{
@@ -65,11 +68,11 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Creates a new file object from the specified path.
*
- * @param path DOCUMENT ME!
+ * @param path the path.
*
- * @return DOCUMENT ME!
+ * @return A new file object.
*/
public File createFileObject(String path)
{
@@ -92,13 +95,16 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Creates a new folder with a unique name in the specified directory and
+ * returns a {@link File} object representing the new directory.
*
- * @param containingDir DOCUMENT ME!
+ * @param containingDir the directory to contain the new folder
+ * (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return A {@link File} object representing the new directory.
*
- * @throws IOException DOCUMENT ME!
+ * @throws IOException if an exception occurs while creating the new
+ * directory.
*/
public abstract File createNewFolder(File containingDir)
throws IOException;
@@ -118,9 +124,9 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the default directory.
*
- * @return DOCUMENT ME!
+ * @return The default directory.
*/
public File getDefaultDirectory()
{
@@ -128,12 +134,16 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns an array containing the files in the given directory. The
+ * <code>useFileHiding</code> controls whether or not hidden files are
+ * included in the result.
*
- * @param dir DOCUMENT ME!
- * @param useFileHiding DOCUMENT ME!
+ * @param dir the directory (if <code>null</code>
+ * @param useFileHiding a flag that controls whether or not hidden files are
+ * included in the result (pass in <code>true</code> to
+ * exclude hidden files).
*
- * @return DOCUMENT ME!
+ * @return The files in the given directory (possibly <code>null</code>).
*/
public File[] getFiles(File dir, boolean useFileHiding)
{
@@ -161,6 +171,7 @@ public abstract class FileSystemView
{
if (File.separator.equals("/"))
defaultFileSystemView = new UnixFileSystemView();
+ // FIXME: need to implement additional views
// else if (File.Separator.equals("\"))
// return new Win32FileSystemView();
// else
@@ -170,9 +181,9 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the home directory for the current user.
*
- * @return DOCUMENT ME!
+ * @return The home directory for the current user.
*/
public File getHomeDirectory()
{
@@ -180,11 +191,12 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the parent directory for the given file/directory.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return The parent directory (or <code>null</code> if there is no parent
+ * directory).
*/
public File getParentDirectory(File f)
{
@@ -194,9 +206,14 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
+ * Returns an array containing the file system roots. On Unix-like platforms,
+ * this array will contain just a single item ("/"), while other platforms
+ * may return multiple roots.
+ * <p>
+ * This method is implemented to return <code>null</code>, subclasses must
+ * override this method.
+ *
+ * @return An array containing the file system roots.
*/
public File[] getRoots()
{
@@ -205,11 +222,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the name of a file as it would be displayed by the underlying
+ * system. This implementation returns <code>null</code>, subclasses must
+ * override.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>null</code>.
*/
public String getSystemDisplayName(File f)
{
@@ -217,11 +236,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the icon that would be displayed for the given file by the
+ * underlying system. This implementation returns <code>null</code>,
+ * subclasses must override.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>null</code>.
*/
public Icon getSystemIcon(File f)
{
@@ -229,11 +250,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the type description of a file that would be displayed by the
+ * underlying system. This implementation returns <code>null</code>,
+ * subclasses must override.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>null</code>.
*/
public String getSystemTypeDescription(File f)
{
@@ -253,11 +276,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the given directory represents a disk
+ * drive, and <code>false</code> otherwise. This default implementation
+ * always returns <code>false</code>.
*
- * @param dir DOCUMENT ME!
+ * @param dir the directory.
*
- * @return DOCUMENT ME!
+ * @return <code>false</code>.
*/
public boolean isDrive(File dir)
{
@@ -265,11 +290,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if <code>f</code> is a file or directory, and
+ * <code>false</code> otherwise.
*
- * @param f DOCUMENT ME!
+ * @param f the file/directory.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if <code>f</code> is a file or directory, and
+ * <code>false</code> otherwise.
*/
public boolean isFileSystem(File f)
{
@@ -277,11 +304,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the given directory is a file system root,
+ * and <code>false</code> otherwise.
*
- * @param dir DOCUMENT ME!
+ * @param dir the directory.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the given directory is a file system root,
+ * and <code>false</code> otherwise.
*/
public boolean isFileSystemRoot(File dir)
{
@@ -296,11 +325,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the given directory represents a floppy
+ * drive, and <code>false</code> otherwise. This default implementation
+ * always returns <code>false</code>.
*
- * @param dir DOCUMENT ME!
+ * @param dir the directory.
*
- * @return DOCUMENT ME!
+ * @return <code>false</code>.
*/
public boolean isFloppyDrive(File dir)
{
@@ -308,11 +339,13 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the given file is hidden, and
+ * <code>false</code> otherwise.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the given file is hidden, and
+ * <code>false</code> otherwise.
*/
public boolean isHiddenFile(File f)
{
@@ -320,12 +353,14 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if <code>folder</code> is the parent of
+ * <code>file</code>, and <code>false</code> otherwise.
*
- * @param folder DOCUMENT ME!
- * @param file DOCUMENT ME!
+ * @param folder the folder (<code>null</code> not permitted).
+ * @param file the file (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if <code>folder</code> is the parent of
+ * <code>file</code>, and <code>false</code> otherwise.
*/
public boolean isParent(File folder, File file)
{
@@ -349,11 +384,14 @@ public abstract class FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns <code>true</code> if the file is traversable, and
+ * <code>false</code> otherwise. Here, all directories are considered
+ * traversable, and files are considered non-traversable.
*
- * @param f DOCUMENT ME!
+ * @param f the file or directory (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return <code>true</code> if the file is traversable, and
+ * <code>false</code> otherwise.
*/
public Boolean isTraversable(File f)
{
diff --git a/javax/swing/filechooser/UnixFileSystemView.java b/javax/swing/filechooser/UnixFileSystemView.java
index f2360ec52..c2f65965e 100644
--- a/javax/swing/filechooser/UnixFileSystemView.java
+++ b/javax/swing/filechooser/UnixFileSystemView.java
@@ -43,21 +43,31 @@ import javax.swing.Icon;
/**
- * DOCUMENT ME!
+ * A concrete implementation of {@link FileSystemView} that is appropriate for
+ * Unix-like systems.
+ *
+ * @see FileSystemView#getFileSystemView()
*/
class UnixFileSystemView extends FileSystemView
{
- /** DOCUMENT ME! */
+ /** The default name for new folders. */
private static final String NEW_FOLDER_NAME = "NewFolder";
/**
- * DOCUMENT ME!
+ * Creates a new folder with a unique name in the specified directory and
+ * returns a {@link File} object representing the new directory. The name
+ * of the new folder is <code>NewFolder</code> or, if a directory or file
+ * with that name already exists, <code>NewFolder.n</code> where
+ * <code>n</code> is the lowest integer greater than zero that results in
+ * a unique directory name.
*
- * @param containingDir DOCUMENT ME!
+ * @param containingDir the directory to contain the new folder
+ * (<code>null</code> not permitted).
*
- * @return DOCUMENT ME!
+ * @return A {@link File} object representing the new directory.
*
- * @throws IOException DOCUMENT ME!
+ * @throws IOException if an exception occurs while creating the new
+ * directory.
*/
public File createNewFolder(File containingDir) throws IOException
{
@@ -82,9 +92,9 @@ class UnixFileSystemView extends FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns an array containing the file system root.
*
- * @return DOCUMENT ME!
+ * @return An array containing the file system root.
*/
public File[] getRoots()
{
@@ -92,11 +102,12 @@ class UnixFileSystemView extends FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the name of a file as it would be displayed by the underlying
+ * system. This method is NOT YET IMPLEMENTED.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>null</code>.
*/
public String getSystemDisplayName(File f)
{
@@ -105,11 +116,12 @@ class UnixFileSystemView extends FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the icon that would be displayed for the given file by the
+ * underlying system. This method is NOT YET IMPLEMENTED.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>null</code>.
*/
public Icon getSystemIcon(File f)
{
@@ -118,11 +130,12 @@ class UnixFileSystemView extends FileSystemView
}
/**
- * DOCUMENT ME!
+ * Returns the description of a file that would be displayed by the
+ * underlying system. This method is NOT YET IMPLEMENTED.
*
- * @param f DOCUMENT ME!
+ * @param f the file.
*
- * @return DOCUMENT ME!
+ * @return <code>null</code>.
*/
public String getSystemTypeDescription(File f)
{
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 64a9b2d08..ab779945b 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -397,8 +397,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"DesktopIcon.border", new BorderUIResource.CompoundBorderUIResource(null,
null),
"EditorPane.background", new ColorUIResource(Color.white),
- "EditorPane.border",
- new BorderUIResource(BasicBorders.getMarginBorder()),
+ "EditorPane.border", BasicBorders.getMarginBorder(),
"EditorPane.caretBlinkRate", new Integer(500),
"EditorPane.caretForeground", new ColorUIResource(Color.black),
"EditorPane.font", new FontUIResource("Serif", Font.PLAIN, 12),
@@ -985,7 +984,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
new BorderUIResource(BasicBorders.getMarginBorder()),
"TextArea.caretBlinkRate", new Integer(500),
"TextArea.caretForeground", new ColorUIResource(Color.black),
- "TextArea.font", new FontUIResource("Monospaced", Font.PLAIN, 12),
+ "TextArea.font", new FontUIResource("MonoSpaced", Font.PLAIN, 12),
"TextArea.foreground", new ColorUIResource(Color.black),
"TextArea.inactiveForeground", new ColorUIResource(Color.gray),
"TextArea.keyBindings", new JTextComponent.KeyBinding[] {
@@ -1032,8 +1031,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TextField.selectionBackground", new ColorUIResource(Color.black),
"TextField.selectionForeground", new ColorUIResource(Color.white),
"TextPane.background", new ColorUIResource(Color.white),
- "TextPane.border",
- new BorderUIResource(BasicBorders.getMarginBorder()),
+ "TextPane.border", BasicBorders.getMarginBorder(),
"TextPane.caretBlinkRate", new Integer(500),
"TextPane.caretForeground", new ColorUIResource(Color.black),
"TextPane.font", new FontUIResource("Serif", Font.PLAIN, 12),
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java
index 277b25a00..808ed2763 100644
--- a/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -185,15 +185,30 @@ public class BasicScrollPaneUI extends ScrollPaneUI
*/
public void propertyChange(PropertyChangeEvent e)
{
- if (e.getPropertyName().equals("viewport"))
+ String propName = e.getPropertyName();
+ if (propName.equals("viewport"))
updateViewport(e);
- else if (e.getPropertyName().equals("rowHeader"))
+ else if (propName.equals("rowHeader"))
updateRowHeader(e);
- else if (e.getPropertyName().equals("columnHeader"))
+ else if (propName.equals("columnHeader"))
updateColumnHeader(e);
- else if (e.getPropertyName().equals("horizontalScrollBarPolicy")
+ else if (propName.equals("horizontalScrollBarPolicy")
|| e.getPropertyName().equals("verticalScrollBarPolicy"))
updateScrollBarDisplayPolicy(e);
+ else if (propName.equals("verticalScrollBar"))
+ {
+ JScrollBar oldSb = (JScrollBar) e.getOldValue();
+ oldSb.getModel().removeChangeListener(vsbChangeListener);
+ JScrollBar newSb = (JScrollBar) e.getNewValue();
+ newSb.getModel().addChangeListener(vsbChangeListener);
+ }
+ else if (propName.equals("horizontalScrollBar"))
+ {
+ JScrollBar oldSb = (JScrollBar) e.getOldValue();
+ oldSb.getModel().removeChangeListener(hsbChangeListener);
+ JScrollBar newSb = (JScrollBar) e.getNewValue();
+ newSb.getModel().addChangeListener(hsbChangeListener);
+ }
}
}
diff --git a/javax/swing/plaf/basic/BasicToolBarUI.java b/javax/swing/plaf/basic/BasicToolBarUI.java
index d02922f74..ef4ed835f 100644
--- a/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -596,6 +596,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
floatingBorderColor = UIManager.getColor("ToolBar.floatingForeground");
floatingColor = UIManager.getColor("ToolBar.floatingBackground");
+ setRolloverBorders(toolBar.isRollover());
}
/**
diff --git a/javax/swing/plaf/metal/MetalScrollPaneUI.java b/javax/swing/plaf/metal/MetalScrollPaneUI.java
index 31fd19d26..d5bf175f9 100644
--- a/javax/swing/plaf/metal/MetalScrollPaneUI.java
+++ b/javax/swing/plaf/metal/MetalScrollPaneUI.java
@@ -49,11 +49,6 @@ import javax.swing.plaf.basic.BasicScrollPaneUI;
public class MetalScrollPaneUI
extends BasicScrollPaneUI
{
-
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for JScrollPanes. */
- private static MetalScrollPaneUI instance = null;
-
/**
* Constructs a new instance of <code>MetalScrollPaneUI</code>.
*/
@@ -71,8 +66,6 @@ public class MetalScrollPaneUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalScrollPaneUI();
- return instance;
+ return new MetalScrollPaneUI();
}
}
diff --git a/javax/swing/text/WrappedPlainView.java b/javax/swing/text/WrappedPlainView.java
index 02200d254..5b70c9df2 100644
--- a/javax/swing/text/WrappedPlainView.java
+++ b/javax/swing/text/WrappedPlainView.java
@@ -226,7 +226,8 @@ public class WrappedPlainView extends BoxView implements TabExpander
protected int calculateBreakPosition(int p0, int p1)
{
Container c = getContainer();
- Rectangle alloc = c.getBounds();
+ Rectangle alloc = c.isValid() ? c.getBounds()
+ : new Rectangle(c.getPreferredSize());
updateMetrics();
try
{