Merge jdk7-b70
authoryan
Tue, 18 Aug 2009 23:40:15 -0700
changeset 1596893bcca951b7
parent 1583 abac33c4bd67
parent 1595 5ff018677b2d
child 1597 de49d1343d86
Merge
     1.1 --- a/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java	Fri Aug 14 08:51:56 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java	Tue Aug 18 23:40:15 2009 -0700
     1.3 @@ -48,7 +48,7 @@
     1.4      }
     1.5  
     1.6      private static boolean isValid(Class<?> type, Method method) {
     1.7 -        return (method != null) && type.equals(method.getDeclaringClass());
     1.8 +        return (method != null) && method.getDeclaringClass().isAssignableFrom(type);
     1.9      }
    1.10  
    1.11      @Override
     2.1 --- a/src/share/classes/java/lang/Character.java	Fri Aug 14 08:51:56 2009 -0700
     2.2 +++ b/src/share/classes/java/lang/Character.java	Tue Aug 18 23:40:15 2009 -0700
     2.3 @@ -38,7 +38,7 @@
     2.4   * a character's category (lowercase letter, digit, etc.) and for converting
     2.5   * characters from uppercase to lowercase and vice versa.
     2.6   * <p>
     2.7 - * Character information is based on the Unicode Standard, version 4.0.
     2.8 + * Character information is based on the Unicode Standard, version 5.1.0.
     2.9   * <p>
    2.10   * The methods and data of class <code>Character</code> are defined by
    2.11   * the information in the <i>UnicodeData</i> file that is part of the
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/share/classes/javax/swing/JLayer.java	Tue Aug 18 23:40:15 2009 -0700
     3.3 @@ -0,0 +1,788 @@
     3.4 +/*
     3.5 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
     3.6 + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     3.7 + */
     3.8 +
     3.9 +package javax.swing;
    3.10 +
    3.11 +import javax.swing.plaf.LayerUI;
    3.12 +import java.awt.*;
    3.13 +import java.awt.event.*;
    3.14 +import java.beans.PropertyChangeEvent;
    3.15 +import java.beans.PropertyChangeListener;
    3.16 +import java.io.IOException;
    3.17 +import java.io.ObjectInputStream;
    3.18 +import java.io.Serializable;
    3.19 +import java.lang.ref.WeakReference;
    3.20 +import java.util.ArrayList;
    3.21 +import java.util.Iterator;
    3.22 +import java.security.AccessController;
    3.23 +import java.security.PrivilegedAction;
    3.24 +
    3.25 +/**
    3.26 + * {@code JLayer} is a universal decorator for Swing components
    3.27 + * which enables you to implement various advanced painting effects as well as
    3.28 + * receive notifications of all {@code AWTEvent}s generated within its borders.
    3.29 + * <p/>
    3.30 + * {@code JLayer} delegates the handling of painting and input events to a
    3.31 + * {@link javax.swing.plaf.LayerUI} object, which performs the actual decoration.
    3.32 + * <p/>
    3.33 + * The custom painting implemented in the {@code LayerUI} and events notification
    3.34 + * work for the JLayer itself and all its subcomponents.
    3.35 + * This combination enables you to enrich existing components
    3.36 + * by adding new advanced functionality such as temporary locking of a hierarchy,
    3.37 + * data tips for compound components, enhanced mouse scrolling etc and so on.
    3.38 + * <p/>
    3.39 + * {@code JLayer} is a good solution if you only need to do custom painting
    3.40 + * over compound component or catch input events from its subcomponents.
    3.41 + * <pre>
    3.42 + *         // create a component to be decorated with the layer
    3.43 + *        JPanel panel = new JPanel();
    3.44 + *        panel.add(new JButton("JButton"));
    3.45 + *        // This custom layerUI will fill the layer with translucent green
    3.46 + *        // and print out all mouseMotion events generated within its borders
    3.47 + *        LayerUI&lt;JPanel&gt; layerUI = new LayerUI&lt;JPanel&gt;() {
    3.48 + *            public void paint(Graphics g, JCompo  nent c) {
    3.49 + *                // paint the layer as is
    3.50 + *                super.paint(g, c);
    3.51 + *                // fill it with the translucent green
    3.52 + *                g.setColor(new Color(0, 128, 0, 128));
    3.53 + *                g.fillRect(0, 0, c.getWidth(), c.getHeight());
    3.54 + *            }
    3.55 + *            // overridden method which catches MouseMotion events
    3.56 + *            public void eventDispatched(AWTEvent e, JLayer&lt;JPanel&gt; l) {
    3.57 + *                System.out.println("AWTEvent detected: " + e);
    3.58 + *            }
    3.59 + *        };
    3.60 + *        // create the layer for the panel using our custom layerUI
    3.61 + *        JLayer&lt;JPanel&gt; layer = new JLayer&lt;JPanel&gt;(panel, layerUI);
    3.62 + *        // work with the layer as with any other Swing component
    3.63 + *        frame.add(layer);
    3.64 + * </pre>
    3.65 + *
    3.66 + * <b>Note:</b> {@code JLayer} doesn't support the following methods:
    3.67 + * <ul>
    3.68 + * <li>{@link Container#add(java.awt.Component)}</li>
    3.69 + * <li>{@link Container#add(String, java.awt.Component)}</li>
    3.70 + * <li>{@link Container#add(java.awt.Component, int)}</li>
    3.71 + * <li>{@link Container#add(java.awt.Component, Object)}</li>
    3.72 + * <li>{@link Container#add(java.awt.Component, Object, int)}</li>
    3.73 + * </ul>
    3.74 + * using any of of them will cause {@code UnsupportedOperationException} to be thrown,
    3.75 + * to add a component to {@code JLayer}
    3.76 + * use {@link #setView(Component)} or {@link #setGlassPane(JPanel)}.
    3.77 + *
    3.78 + * @param <V> the type of {@code JLayer}'s view component
    3.79 + *
    3.80 + * @see #JLayer(Component)
    3.81 + * @see #setView(Component)
    3.82 + * @see #getView()
    3.83 + * @see javax.swing.plaf.LayerUI
    3.84 + * @see #JLayer(Component, LayerUI)
    3.85 + * @see #setUI(javax.swing.plaf.LayerUI)
    3.86 + * @see #getUI()
    3.87 + * @since 1.7
    3.88 + *
    3.89 + * @author Alexander Potochkin
    3.90 + */
    3.91 +public final class JLayer<V extends Component>
    3.92 +        extends JComponent
    3.93 +        implements Scrollable, PropertyChangeListener {
    3.94 +    private V view;
    3.95 +    // this field is necessary because JComponent.ui is transient
    3.96 +    // when layerUI is serializable
    3.97 +    private LayerUI<? super V> layerUI;
    3.98 +    private JPanel glassPane;
    3.99 +    private boolean isPainting;
   3.100 +    private static final DefaultLayerLayout sharedLayoutInstance =
   3.101 +            new DefaultLayerLayout();
   3.102 +    private long eventMask;
   3.103 +
   3.104 +    private static final LayerEventController eventController =
   3.105 +            new LayerEventController();
   3.106 +
   3.107 +    private static final long ACCEPTED_EVENTS =
   3.108 +            AWTEvent.COMPONENT_EVENT_MASK |
   3.109 +                    AWTEvent.CONTAINER_EVENT_MASK |
   3.110 +                    AWTEvent.FOCUS_EVENT_MASK |
   3.111 +                    AWTEvent.KEY_EVENT_MASK |
   3.112 +                    AWTEvent.MOUSE_WHEEL_EVENT_MASK |
   3.113 +                    AWTEvent.MOUSE_MOTION_EVENT_MASK |
   3.114 +                    AWTEvent.MOUSE_EVENT_MASK |
   3.115 +                    AWTEvent.INPUT_METHOD_EVENT_MASK |
   3.116 +                    AWTEvent.HIERARCHY_EVENT_MASK |
   3.117 +                    AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK;
   3.118 +
   3.119 +    /**
   3.120 +     * Creates a new {@code JLayer} object with a {@code null} view component
   3.121 +     * and {@code null} {@link javax.swing.plaf.LayerUI}.
   3.122 +     *
   3.123 +     * @see #setView
   3.124 +     * @see #setUI
   3.125 +     */
   3.126 +    public JLayer() {
   3.127 +        this(null);
   3.128 +    }
   3.129 +
   3.130 +    /**
   3.131 +     * Creates a new {@code JLayer} object
   3.132 +     * with {@code null} {@link javax.swing.plaf.LayerUI}.
   3.133 +     *
   3.134 +     * @param view the component to be decorated by this {@code JLayer}
   3.135 +     *
   3.136 +     * @see #setUI
   3.137 +     */
   3.138 +    public JLayer(V view) {
   3.139 +        this(view, null);
   3.140 +    }
   3.141 +
   3.142 +    /**
   3.143 +     * Creates a new {@code JLayer} object with the specified view component
   3.144 +     * and {@link javax.swing.plaf.LayerUI} object.
   3.145 +     *
   3.146 +     * @param view the component to be decorated
   3.147 +     * @param ui the {@link javax.swing.plaf.LayerUI} delegate
   3.148 +     * to be used by this {@code JLayer}
   3.149 +     */
   3.150 +    public JLayer(V view, LayerUI<V> ui) {
   3.151 +        setLayout(sharedLayoutInstance);
   3.152 +        setGlassPane(createGlassPane());
   3.153 +        setView(view);
   3.154 +        setUI(ui);
   3.155 +    }
   3.156 +
   3.157 +    /**
   3.158 +     * Returns the {@code JLayer}'s view component or {@code null}.
   3.159 +     * <br/>This is a bound property.
   3.160 +     *
   3.161 +     * @return the {@code JLayer}'s view component
   3.162 +     *         or {@code null} if none exists
   3.163 +     *
   3.164 +     * @see #setView(V)
   3.165 +     */
   3.166 +    public V getView() {
   3.167 +        return view;
   3.168 +    }
   3.169 +
   3.170 +    /**
   3.171 +     * Sets the {@code JLayer}'s view component, which can be {@code null}.
   3.172 +     * <br/>This is a bound property.
   3.173 +     *
   3.174 +     * @param view the view component for this {@code JLayer}
   3.175 +     *
   3.176 +     * @see #getView()
   3.177 +     */
   3.178 +    public void setView(V view) {
   3.179 +        Component oldView = getView();
   3.180 +        if (oldView != null) {
   3.181 +            super.remove(oldView);
   3.182 +        }
   3.183 +        if (view != null) {
   3.184 +            super.addImpl(view, null, getComponentCount());
   3.185 +        }
   3.186 +        this.view = view;
   3.187 +        firePropertyChange("view", oldView, view);
   3.188 +        revalidate();
   3.189 +        repaint();
   3.190 +    }
   3.191 +
   3.192 +    /**
   3.193 +     * Sets the {@link javax.swing.plaf.LayerUI} which will perform painting
   3.194 +     * and receive input events for this {@code JLayer}.
   3.195 +     *
   3.196 +     * @param ui the {@link javax.swing.plaf.LayerUI} for this {@code JLayer}
   3.197 +     */
   3.198 +    public void setUI(LayerUI<? super V> ui) {
   3.199 +        this.layerUI = ui;
   3.200 +        super.setUI(ui);
   3.201 +    }
   3.202 +
   3.203 +    /**
   3.204 +     * Returns the {@link javax.swing.plaf.LayerUI} for this {@code JLayer}.
   3.205 +     *
   3.206 +     * @return the {@code LayerUI} for this {@code JLayer}
   3.207 +     */
   3.208 +    public LayerUI<? super V> getUI() {
   3.209 +        return layerUI;
   3.210 +    }
   3.211 +
   3.212 +    /**
   3.213 +     * Returns the {@code JLayer}'s glassPane component or {@code null}.
   3.214 +     * <br/>This is a bound property.
   3.215 +     *
   3.216 +     * @return the {@code JLayer}'s glassPane component
   3.217 +     *         or {@code null} if none exists
   3.218 +     *
   3.219 +     * @see #setGlassPane(JPanel)
   3.220 +     */
   3.221 +    public JPanel getGlassPane() {
   3.222 +        return glassPane;
   3.223 +    }
   3.224 +
   3.225 +    /**
   3.226 +     * Sets the {@code JLayer}'s glassPane component, which can be {@code null}.
   3.227 +     * <br/>This is a bound property.
   3.228 +     *
   3.229 +     * @param glassPane the glassPane component of this {@code JLayer}
   3.230 +     *
   3.231 +     * @see #getGlassPane()
   3.232 +     */
   3.233 +    public void setGlassPane(JPanel glassPane) {
   3.234 +        Component oldGlassPane = getGlassPane();
   3.235 +        if (oldGlassPane != null) {
   3.236 +            super.remove(oldGlassPane);
   3.237 +        }
   3.238 +        if (glassPane != null) {
   3.239 +            super.addImpl(glassPane, null, 0);
   3.240 +        }
   3.241 +        this.glassPane = glassPane;
   3.242 +        firePropertyChange("glassPane", oldGlassPane, glassPane);
   3.243 +        revalidate();
   3.244 +        repaint();
   3.245 +    }
   3.246 +
   3.247 +    /**
   3.248 +     * Called by the constructor methods to create a default {@code glassPane}.
   3.249 +     * By default this method creates a new JPanel with visibility set to true
   3.250 +     * and opacity set to false.
   3.251 +     *
   3.252 +     * @return the default {@code glassPane}
   3.253 +     */
   3.254 +    public JPanel createGlassPane() {
   3.255 +        return new DefaultLayerGlassPane();
   3.256 +    }
   3.257 +
   3.258 +    /**
   3.259 +     * This method is not supported by {@code JLayer}
   3.260 +     * and always throws {@code UnsupportedOperationException}
   3.261 +     *
   3.262 +     * @throws UnsupportedOperationException this method is not supported
   3.263 +     *
   3.264 +     * @see #setView(Component)
   3.265 +     * @see #setGlassPane(Component)
   3.266 +     */
   3.267 +    protected void addImpl(Component comp, Object constraints, int index) {
   3.268 +        throw new UnsupportedOperationException(
   3.269 +                "Adding components to JLayer is not supported, " +
   3.270 +                        "use setView() or setGlassPane() instead");
   3.271 +    }
   3.272 +
   3.273 +    /**
   3.274 +     * {@inheritDoc}
   3.275 +     */
   3.276 +    public void remove(Component comp) {
   3.277 +        if (comp == getView()) {
   3.278 +            setView(null);
   3.279 +        } else if (comp == getGlassPane()) {
   3.280 +            setGlassPane(null);
   3.281 +        } else {
   3.282 +            super.remove(comp);
   3.283 +        }
   3.284 +    }
   3.285 +
   3.286 +    /**
   3.287 +     * {@inheritDoc}
   3.288 +     */
   3.289 +    public void removeAll() {
   3.290 +        setView(null);
   3.291 +        setGlassPane(null);
   3.292 +    }
   3.293 +
   3.294 +    /**
   3.295 +     * Delegates all painting to the {@link javax.swing.plaf.LayerUI} object.
   3.296 +     *
   3.297 +     * @param g the {@code Graphics} to render to
   3.298 +     */
   3.299 +    public void paint(Graphics g) {
   3.300 +        if (!isPainting) {
   3.301 +            isPainting = true;
   3.302 +            super.paintComponent(g);
   3.303 +            isPainting = false;
   3.304 +        } else {
   3.305 +            super.paint(g);
   3.306 +        }
   3.307 +    }
   3.308 +
   3.309 +    /**
   3.310 +     * This method is empty, because all painting is done by
   3.311 +     * {@link #paint(Graphics)} and
   3.312 +     * {@link javax.swing.plaf.LayerUI#update(Graphics, JComponent)} methods
   3.313 +     */
   3.314 +    protected void paintComponent(Graphics g) {
   3.315 +    }
   3.316 +
   3.317 +    /**
   3.318 +     * To enable the correct painting of the {@code glassPane} and view component,
   3.319 +     * the {@code JLayer} overrides the default implementation of
   3.320 +     * this method to return {@code false} when the {@code glassPane} is visible.
   3.321 +     *
   3.322 +     * @return false if {@code JLayer}'s {@code glassPane} is visible
   3.323 +     */
   3.324 +    public boolean isOptimizedDrawingEnabled() {
   3.325 +        return !glassPane.isVisible();
   3.326 +    }
   3.327 +
   3.328 +    /**
   3.329 +     * {@inheritDoc}
   3.330 +     */
   3.331 +    public void propertyChange(PropertyChangeEvent evt) {
   3.332 +        if (getUI() != null) {
   3.333 +            getUI().applyPropertyChange(evt, this);
   3.334 +        }
   3.335 +    }
   3.336 +
   3.337 +    /**
   3.338 +     * Sets the bitmask of event types to receive by this {@code JLayer}.
   3.339 +     * Here is the list of the supported event types:
   3.340 +     * <ul>
   3.341 +     * <li>AWTEvent.COMPONENT_EVENT_MASK</li>
   3.342 +     * <li>AWTEvent.CONTAINER_EVENT_MASK</li>
   3.343 +     * <li>AWTEvent.FOCUS_EVENT_MASK</li>
   3.344 +     * <li>AWTEvent.KEY_EVENT_MASK</li>
   3.345 +     * <li>AWTEvent.MOUSE_WHEEL_EVENT_MASK</li>
   3.346 +     * <li>AWTEvent.MOUSE_MOTION_EVENT_MASK</li>
   3.347 +     * <li>AWTEvent.MOUSE_EVENT_MASK</li>
   3.348 +     * <li>AWTEvent.INPUT_METHOD_EVENT_MASK</li>
   3.349 +     * <li>AWTEvent.HIERARCHY_EVENT_MASK</li>
   3.350 +     * <li>AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK</li>
   3.351 +     * </ul>
   3.352 +     * <p/>
   3.353 +     * If {@code LayerUI} is installed,
   3.354 +     * {@link javax.swing.plaf.LayerUI#eventDispatched(AWTEvent, JLayer)} method
   3.355 +     * will only receive events that match the event mask.
   3.356 +     * <p/>
   3.357 +     * The following example shows how to correclty use this method
   3.358 +     * in the {@code LayerUI} implementations:
   3.359 +     * <pre>
   3.360 +     *    public void installUI(JComponent c) {
   3.361 +     *       super.installUI(c);
   3.362 +     *       JLayer l = (JLayer) c;
   3.363 +     *       // this LayerUI will receive only key and focus events
   3.364 +     *       l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
   3.365 +     *    }
   3.366 +     *
   3.367 +     *    public void uninstallUI(JComponent c) {
   3.368 +     *       super.uninstallUI(c);
   3.369 +     *       JLayer l = (JLayer) c;
   3.370 +     *       // JLayer must be returned to its initial state
   3.371 +     *       l.setLayerEventMask(0);
   3.372 +     *    }
   3.373 +     * </pre>
   3.374 +     *
   3.375 +     * By default {@code JLayer} receives no events.
   3.376 +     *
   3.377 +     * @param layerEventMask the bitmask of event types to receive
   3.378 +     *
   3.379 +     * @throws IllegalArgumentException if the {@code layerEventMask} parameter
   3.380 +     * contains unsupported event types
   3.381 +     * @see #getLayerEventMask()
   3.382 +     */
   3.383 +    public void setLayerEventMask(long layerEventMask) {
   3.384 +        if (layerEventMask != (layerEventMask & ACCEPTED_EVENTS)) {
   3.385 +            throw new IllegalArgumentException(
   3.386 +                    "The event bitmask contains unsupported event types");
   3.387 +        }
   3.388 +        long oldEventMask = getLayerEventMask();
   3.389 +        this.eventMask = layerEventMask;
   3.390 +        firePropertyChange("layerEventMask", oldEventMask, layerEventMask);
   3.391 +        if (layerEventMask != oldEventMask) {
   3.392 +            disableEvents(oldEventMask);
   3.393 +            enableEvents(eventMask);
   3.394 +            eventController.updateAWTEventListener(this);
   3.395 +        }
   3.396 +    }
   3.397 +
   3.398 +    /**
   3.399 +     * Returns the bitmap of event mask to receive by this {@code JLayer}
   3.400 +     * and its {@code LayerUI}.
   3.401 +     * <p/>
   3.402 +     * It means that {@link javax.swing.plaf.LayerUI#eventDispatched(AWTEvent, JLayer)} method
   3.403 +     * will only receive events that match the event mask.
   3.404 +     * <p/>
   3.405 +     * By default {@code JLayer} receives no events.
   3.406 +     *
   3.407 +     * @return the bitmask of event types to receive for this {@code JLayer}
   3.408 +     */
   3.409 +    public long getLayerEventMask() {
   3.410 +        return eventMask;
   3.411 +    }
   3.412 +
   3.413 +    /**
   3.414 +     * Delegates its functionality to the {@link javax.swing.plaf.LayerUI#updateUI(JLayer)} method,
   3.415 +     * if {@code LayerUI} is set.
   3.416 +     */
   3.417 +    public void updateUI() {
   3.418 +        if (getUI() != null) {
   3.419 +            getUI().updateUI(this);
   3.420 +        }
   3.421 +    }
   3.422 +
   3.423 +    /**
   3.424 +     * Returns the preferred size of the viewport for a view component.
   3.425 +     * <p/>
   3.426 +     * If the ui delegate of this layer is not {@code null}, this method delegates its
   3.427 +     * implementation to the {@code LayerUI.getPreferredScrollableViewportSize(JLayer)}
   3.428 +     *
   3.429 +     * @return the preferred size of the viewport for a view component
   3.430 +     *
   3.431 +     * @see Scrollable
   3.432 +     * @see LayerUI#getPreferredScrollableViewportSize(JLayer)
   3.433 +     */
   3.434 +    public Dimension getPreferredScrollableViewportSize() {
   3.435 +        if (getUI() != null) {
   3.436 +            return getUI().getPreferredScrollableViewportSize(this);
   3.437 +        }
   3.438 +        return getPreferredSize();
   3.439 +    }
   3.440 +
   3.441 +    /**
   3.442 +     * Returns a scroll increment, which is required for components
   3.443 +     * that display logical rows or columns in order to completely expose
   3.444 +     * one block of rows or columns, depending on the value of orientation.
   3.445 +     * <p/>
   3.446 +     * If the ui delegate of this layer is not {@code null}, this method delegates its
   3.447 +     * implementation to the {@code LayerUI.getScrollableBlockIncrement(JLayer,Rectangle,int,int)}
   3.448 +     *
   3.449 +     * @return the "block" increment for scrolling in the specified direction
   3.450 +     *
   3.451 +     * @see Scrollable
   3.452 +     * @see LayerUI#getScrollableBlockIncrement(JLayer, Rectangle, int, int)
   3.453 +     */
   3.454 +    public int getScrollableBlockIncrement(Rectangle visibleRect,
   3.455 +                                           int orientation, int direction) {
   3.456 +        if (getUI() != null) {
   3.457 +            return getUI().getScrollableBlockIncrement(this, visibleRect,
   3.458 +                    orientation, direction);
   3.459 +        }
   3.460 +        return (orientation == SwingConstants.VERTICAL) ? visibleRect.height :
   3.461 +                visibleRect.width;
   3.462 +    }
   3.463 +
   3.464 +    /**
   3.465 +     * Returns {@code false} to indicate that the height of the viewport does not
   3.466 +     * determine the height of the layer, unless the preferred height
   3.467 +     * of the layer is smaller than the height of the viewport.
   3.468 +     * <p/>
   3.469 +     * If the ui delegate of this layer is not null, this method delegates its
   3.470 +     * implementation to the {@code LayerUI.getScrollableTracksViewportHeight(JLayer)}
   3.471 +     *
   3.472 +     * @return whether the layer should track the height of the viewport
   3.473 +     *
   3.474 +     * @see Scrollable
   3.475 +     * @see LayerUI#getScrollableTracksViewportHeight(JLayer)
   3.476 +     */
   3.477 +    public boolean getScrollableTracksViewportHeight() {
   3.478 +        if (getUI() != null) {
   3.479 +            return getUI().getScrollableTracksViewportHeight(this);
   3.480 +        }
   3.481 +        if (getParent() instanceof JViewport) {
   3.482 +            return ((getParent()).getHeight() > getPreferredSize().height);
   3.483 +        }
   3.484 +        return false;
   3.485 +    }
   3.486 +
   3.487 +    /**
   3.488 +     * Returns {@code false} to indicate that the width of the viewport does not
   3.489 +     * determine the width of the layer, unless the preferred width
   3.490 +     * of the layer is smaller than the width of the viewport.
   3.491 +     * <p/>
   3.492 +     * If the ui delegate of this layer is not null, this method delegates its
   3.493 +     * implementation to the {@code LayerUI.getScrollableTracksViewportWidth(JLayer)}
   3.494 +     *
   3.495 +     * @return whether the layer should track the width of the viewport
   3.496 +     *
   3.497 +     * @see Scrollable
   3.498 +     * @see LayerUI#getScrollableTracksViewportWidth(JLayer)
   3.499 +     */
   3.500 +    public boolean getScrollableTracksViewportWidth() {
   3.501 +        if (getUI() != null) {
   3.502 +            return getUI().getScrollableTracksViewportWidth(this);
   3.503 +        }
   3.504 +        if (getParent() instanceof JViewport) {
   3.505 +            return ((getParent()).getWidth() > getPreferredSize().width);
   3.506 +        }
   3.507 +        return false;
   3.508 +    }
   3.509 +
   3.510 +    /**
   3.511 +     * Returns a scroll increment, which is required for components
   3.512 +     * that display logical rows or columns in order to completely expose
   3.513 +     * one new row or column, depending on the value of orientation.
   3.514 +     * Ideally, components should handle a partially exposed row or column
   3.515 +     * by returning the distance required to completely expose the item.
   3.516 +     * <p/>
   3.517 +     * Scrolling containers, like {@code JScrollPane}, will use this method
   3.518 +     * each time the user requests a unit scroll.
   3.519 +     * <p/>
   3.520 +     * If the ui delegate of this layer is not {@code null}, this method delegates its
   3.521 +     * implementation to the {@code LayerUI.getScrollableUnitIncrement(JLayer,Rectangle,int,int)}
   3.522 +     *
   3.523 +     * @return The "unit" increment for scrolling in the specified direction.
   3.524 +     *         This value should always be positive.
   3.525 +     *
   3.526 +     * @see Scrollable
   3.527 +     * @see LayerUI#getScrollableUnitIncrement(JLayer, Rectangle, int, int)
   3.528 +     */
   3.529 +    public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation,
   3.530 +                                          int direction) {
   3.531 +        if (getUI() != null) {
   3.532 +            return getUI().getScrollableUnitIncrement(
   3.533 +                    this, visibleRect, orientation, direction);
   3.534 +        }
   3.535 +        return 1;
   3.536 +    }
   3.537 +
   3.538 +    private void readObject(ObjectInputStream s)
   3.539 +            throws IOException, ClassNotFoundException {
   3.540 +        s.defaultReadObject();
   3.541 +        if (getUI() != null) {
   3.542 +            setUI(getUI());
   3.543 +        }
   3.544 +        if (getLayerEventMask() != 0) {
   3.545 +            eventController.updateAWTEventListener(this);
   3.546 +        }
   3.547 +    }
   3.548 +
   3.549 +    /**
   3.550 +     * static AWTEventListener to be shared with all AbstractLayerUIs
   3.551 +     */
   3.552 +    private static class LayerEventController implements AWTEventListener {
   3.553 +        private ArrayList<WeakReference<JLayer>> layerList =
   3.554 +                new ArrayList<WeakReference<JLayer>>();
   3.555 +
   3.556 +        private long currentEventMask;
   3.557 +
   3.558 +        @SuppressWarnings("unchecked")
   3.559 +        public void eventDispatched(AWTEvent event) {
   3.560 +            Object source = event.getSource();
   3.561 +            if (source instanceof Component) {
   3.562 +                Component component = (Component) source;
   3.563 +                while (component != null) {
   3.564 +                    if (component instanceof JLayer) {
   3.565 +                        JLayer l = (JLayer) component;
   3.566 +                        LayerUI ui = l.getUI();
   3.567 +                        if (ui != null &&
   3.568 +                                isEventEnabled(l.getLayerEventMask(),
   3.569 +                                        event.getID())) {
   3.570 +                            ui.eventDispatched(event, l);
   3.571 +                        }
   3.572 +                    }
   3.573 +                    component = component.getParent();
   3.574 +                }
   3.575 +            }
   3.576 +        }
   3.577 +
   3.578 +        private boolean layerListContains(JLayer l) {
   3.579 +            for (WeakReference<JLayer> layerWeakReference : layerList) {
   3.580 +                if (layerWeakReference.get() == l) {
   3.581 +                    return true;
   3.582 +                }
   3.583 +            }
   3.584 +            return false;
   3.585 +        }
   3.586 +
   3.587 +        private void updateAWTEventListener(JLayer layer) {
   3.588 +            if (!layerListContains(layer) && layer.getLayerEventMask() != 0) {
   3.589 +                layerList.add(new WeakReference<JLayer>(layer));
   3.590 +            }
   3.591 +            long combinedMask = 0;
   3.592 +            Iterator<WeakReference<JLayer>> it = layerList.iterator();
   3.593 +            while (it.hasNext()) {
   3.594 +                WeakReference<JLayer> weakRef = it.next();
   3.595 +                JLayer currLayer = weakRef.get();
   3.596 +                if (currLayer == null) {
   3.597 +                    it.remove();
   3.598 +                } else {
   3.599 +                    combinedMask |= currLayer.getLayerEventMask();
   3.600 +                }
   3.601 +            }
   3.602 +            if (combinedMask == 0) {
   3.603 +                removeAWTEventListener();
   3.604 +                layerList.clear();
   3.605 +            } else if (getCurrentEventMask() != combinedMask) {
   3.606 +                removeAWTEventListener();
   3.607 +                addAWTEventListener(combinedMask);
   3.608 +            }
   3.609 +        }
   3.610 +
   3.611 +        private long getCurrentEventMask() {
   3.612 +            return currentEventMask;
   3.613 +        }
   3.614 +
   3.615 +        private void addAWTEventListener(final long eventMask) {
   3.616 +            AccessController.doPrivileged(new PrivilegedAction<Void>() {
   3.617 +                public Void run() {
   3.618 +                    Toolkit.getDefaultToolkit().
   3.619 +                            addAWTEventListener(LayerEventController.this, eventMask);
   3.620 +                    return null;
   3.621 +                }
   3.622 +            });
   3.623 +            currentEventMask = eventMask;
   3.624 +        }
   3.625 +
   3.626 +        private void removeAWTEventListener() {
   3.627 +            AccessController.doPrivileged(new PrivilegedAction<Void>() {
   3.628 +                public Void run() {
   3.629 +                    Toolkit.getDefaultToolkit().
   3.630 +                            removeAWTEventListener(LayerEventController.this);
   3.631 +                    return null;
   3.632 +                }
   3.633 +            });
   3.634 +            currentEventMask = 0;
   3.635 +        }
   3.636 +
   3.637 +        private boolean isEventEnabled(long eventMask, int id) {
   3.638 +            return (((eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 &&
   3.639 +                    id >= ComponentEvent.COMPONENT_FIRST &&
   3.640 +                    id <= ComponentEvent.COMPONENT_LAST)
   3.641 +                    || ((eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 &&
   3.642 +                    id >= ContainerEvent.CONTAINER_FIRST &&
   3.643 +                    id <= ContainerEvent.CONTAINER_LAST)
   3.644 +                    || ((eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 &&
   3.645 +                    id >= FocusEvent.FOCUS_FIRST &&
   3.646 +                    id <= FocusEvent.FOCUS_LAST)
   3.647 +                    || ((eventMask & AWTEvent.KEY_EVENT_MASK) != 0 &&
   3.648 +                    id >= KeyEvent.KEY_FIRST &&
   3.649 +                    id <= KeyEvent.KEY_LAST)
   3.650 +                    || ((eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 &&
   3.651 +                    id == MouseEvent.MOUSE_WHEEL)
   3.652 +                    || ((eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 &&
   3.653 +                    (id == MouseEvent.MOUSE_MOVED ||
   3.654 +                            id == MouseEvent.MOUSE_DRAGGED))
   3.655 +                    || ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 &&
   3.656 +                    id != MouseEvent.MOUSE_MOVED &&
   3.657 +                    id != MouseEvent.MOUSE_DRAGGED &&
   3.658 +                    id != MouseEvent.MOUSE_WHEEL &&
   3.659 +                    id >= MouseEvent.MOUSE_FIRST &&
   3.660 +                    id <= MouseEvent.MOUSE_LAST)
   3.661 +                    || ((eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 &&
   3.662 +                    id >= InputMethodEvent.INPUT_METHOD_FIRST &&
   3.663 +                    id <= InputMethodEvent.INPUT_METHOD_LAST)
   3.664 +                    || ((eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 &&
   3.665 +                    id == HierarchyEvent.HIERARCHY_CHANGED)
   3.666 +                    || ((eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 &&
   3.667 +                    (id == HierarchyEvent.ANCESTOR_MOVED ||
   3.668 +                            id == HierarchyEvent.ANCESTOR_RESIZED)));
   3.669 +        }
   3.670 +    }
   3.671 +
   3.672 +    /**
   3.673 +     * The default glassPane for the {@link javax.swing.JLayer}.
   3.674 +     * It is a subclass of {@code JPanel} which is non opaque by default.
   3.675 +     */
   3.676 +    private static class DefaultLayerGlassPane extends JPanel {
   3.677 +        /**
   3.678 +         * Creates a new {@link DefaultLayerGlassPane}
   3.679 +         */
   3.680 +        public DefaultLayerGlassPane() {
   3.681 +            setOpaque(false);
   3.682 +        }
   3.683 +
   3.684 +        /**
   3.685 +         * First, implementatation of this method iterates through
   3.686 +         * glassPane's child components and returns {@code true}
   3.687 +         * if any of them is visible and contains passed x,y point.
   3.688 +         * After that it checks if no mouseListeners is attached to this component
   3.689 +         * and no mouse cursor is set, then it returns {@code false},
   3.690 +         * otherwise calls the super implementation of this method.
   3.691 +         *
   3.692 +         * @param x the <i>x</i> coordinate of the point
   3.693 +         * @param y the <i>y</i> coordinate of the point
   3.694 +         * @return true if this component logically contains x,y
   3.695 +         */
   3.696 +        public boolean contains(int x, int y) {
   3.697 +            for (int i = 0; i < getComponentCount(); i++) {
   3.698 +                Component c = getComponent(i);
   3.699 +                Point point = SwingUtilities.convertPoint(this, new Point(x, y), c);
   3.700 +                if(c.isVisible() && c.contains(point)){
   3.701 +                    return true;
   3.702 +                }
   3.703 +            }
   3.704 +            if (getMouseListeners().length == 0
   3.705 +                    && getMouseMotionListeners().length == 0
   3.706 +                    && getMouseWheelListeners().length == 0
   3.707 +                    && !isCursorSet()) {
   3.708 +                return false;
   3.709 +            }
   3.710 +            return super.contains(x, y);
   3.711 +        }
   3.712 +    }
   3.713 +
   3.714 +    /**
   3.715 +     * The default layout manager for the {@link javax.swing.JLayer}.<br/>
   3.716 +     * It places the glassPane on top of the view component
   3.717 +     * and makes it the same size as {@code JLayer},
   3.718 +     * it also makes the view component the same size but minus layer's insets<br/>
   3.719 +     */
   3.720 +    private static class DefaultLayerLayout implements LayoutManager, Serializable {
   3.721 +        /**
   3.722 +         * {@inheritDoc}
   3.723 +         */
   3.724 +        public void layoutContainer(Container parent) {
   3.725 +            JLayer layer = (JLayer) parent;
   3.726 +            Component view = layer.getView();
   3.727 +            Component glassPane = layer.getGlassPane();
   3.728 +            if (view != null) {
   3.729 +                Insets insets = layer.getInsets();
   3.730 +                view.setLocation(insets.left, insets.top);
   3.731 +                view.setSize(layer.getWidth() - insets.left - insets.right,
   3.732 +                        layer.getHeight() - insets.top - insets.bottom);
   3.733 +            }
   3.734 +            if (glassPane != null) {
   3.735 +                glassPane.setLocation(0, 0);
   3.736 +                glassPane.setSize(layer.getWidth(), layer.getHeight());
   3.737 +            }
   3.738 +        }
   3.739 +
   3.740 +        /**
   3.741 +         * {@inheritDoc}
   3.742 +         */
   3.743 +        public Dimension minimumLayoutSize(Container parent) {
   3.744 +            JLayer layer = (JLayer) parent;
   3.745 +            Insets insets = layer.getInsets();
   3.746 +            Dimension ret = new Dimension(insets.left + insets.right,
   3.747 +                    insets.top + insets.bottom);
   3.748 +            Component view = layer.getView();
   3.749 +            if (view != null) {
   3.750 +                Dimension size = view.getMinimumSize();
   3.751 +                ret.width += size.width;
   3.752 +                ret.height += size.height;
   3.753 +            }
   3.754 +            if (ret.width == 0 || ret.height == 0) {
   3.755 +                ret.width = ret.height = 4;
   3.756 +            }
   3.757 +            return ret;
   3.758 +        }
   3.759 +
   3.760 +        /**
   3.761 +         * {@inheritDoc}
   3.762 +         */
   3.763 +        public Dimension preferredLayoutSize(Container parent) {
   3.764 +            JLayer layer = (JLayer) parent;
   3.765 +            Insets insets = layer.getInsets();
   3.766 +            Dimension ret = new Dimension(insets.left + insets.right,
   3.767 +                    insets.top + insets.bottom);
   3.768 +            Component view = layer.getView();
   3.769 +            if (view != null) {
   3.770 +                Dimension size = view.getPreferredSize();
   3.771 +                if (size.width > 0 && size.height > 0) {
   3.772 +                    ret.width += size.width;
   3.773 +                    ret.height += size.height;
   3.774 +                }
   3.775 +            }
   3.776 +            return ret;
   3.777 +        }
   3.778 +
   3.779 +        /**
   3.780 +         * {@inheritDoc}
   3.781 +         */
   3.782 +        public void addLayoutComponent(String name, Component comp) {
   3.783 +        }
   3.784 +
   3.785 +        /**
   3.786 +         * {@inheritDoc}
   3.787 +         */
   3.788 +        public void removeLayoutComponent(Component comp) {
   3.789 +        }
   3.790 +    }
   3.791 +}
   3.792 \ No newline at end of file
     4.1 --- a/src/share/classes/javax/swing/filechooser/FileSystemView.java	Fri Aug 14 08:51:56 2009 -0700
     4.2 +++ b/src/share/classes/javax/swing/filechooser/FileSystemView.java	Tue Aug 18 23:40:15 2009 -0700
     4.3 @@ -37,6 +37,8 @@
     4.4  import java.lang.ref.WeakReference;
     4.5  import java.beans.PropertyChangeListener;
     4.6  import java.beans.PropertyChangeEvent;
     4.7 +import java.security.AccessController;
     4.8 +import java.security.PrivilegedAction;
     4.9  
    4.10  import sun.awt.shell.*;
    4.11  
    4.12 @@ -718,8 +720,13 @@
    4.13          return isFileSystemRoot(dir);
    4.14      }
    4.15  
    4.16 -    public boolean isFloppyDrive(File dir) {
    4.17 -        String path = dir.getAbsolutePath();
    4.18 +    public boolean isFloppyDrive(final File dir) {
    4.19 +        String path = AccessController.doPrivileged(new PrivilegedAction<String>() {
    4.20 +            public String run() {
    4.21 +                return dir.getAbsolutePath();
    4.22 +            }
    4.23 +        });
    4.24 +
    4.25          return (path != null && (path.equals("A:\\") || path.equals("B:\\")));
    4.26      }
    4.27  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/share/classes/javax/swing/plaf/LayerUI.java	Tue Aug 18 23:40:15 2009 -0700
     5.3 @@ -0,0 +1,370 @@
     5.4 +/*
     5.5 + * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
     5.6 + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     5.7 + */
     5.8 +
     5.9 +package javax.swing.plaf;
    5.10 +
    5.11 +import javax.accessibility.Accessible;
    5.12 +import javax.swing.*;
    5.13 +import javax.swing.plaf.ComponentUI;
    5.14 +import java.awt.*;
    5.15 +import java.awt.event.*;
    5.16 +import java.beans.PropertyChangeEvent;
    5.17 +import java.beans.PropertyChangeSupport;
    5.18 +import java.beans.PropertyChangeListener;
    5.19 +import java.io.Serializable;
    5.20 +
    5.21 +/**
    5.22 + * The base class for all {@link javax.swing.JLayer}'s UI delegates.
    5.23 + * <p/>
    5.24 + * {@link #paint(java.awt.Graphics, javax.swing.JComponent)} method performes the
    5.25 + * painting of the {@code JLayer}
    5.26 + * and {@link #eventDispatched(AWTEvent, JLayer)} method is notified
    5.27 + * about any {@code AWTEvent}s which have been generated by a {@code JLayer}
    5.28 + * or any of its subcomponents.
    5.29 + * <p/>
    5.30 + * The {@code LayerUI} differs from the UI delegates of the other components,
    5.31 + * because it is LookAndFeel independent and is not updated by default when
    5.32 + * the system LookAndFeel is changed.
    5.33 + * <p/>
    5.34 + * The subclasses of {@code LayerUI} can either be stateless and shareable
    5.35 + * by multiple {@code JLayer}s or not shareable.
    5.36 + *
    5.37 + * @param <V> one of the super types of {@code JLayer}'s view component
    5.38 + *
    5.39 + * @see JLayer#setUI(LayerUI)
    5.40 + * @see JLayer#setView(Component)
    5.41 + * @see JLayer#getView()
    5.42 + * @since 1.7
    5.43 + *
    5.44 + * @author Alexander Potochkin
    5.45 + */
    5.46 +public class LayerUI<V extends Component>
    5.47 +        extends ComponentUI implements Serializable {
    5.48 +
    5.49 +    private final PropertyChangeSupport propertyChangeSupport =
    5.50 +            new PropertyChangeSupport(this);
    5.51 +
    5.52 +    /**
    5.53 +     * Paints the specified component.
    5.54 +     * Subclasses should override this method and use
    5.55 +     * the specified {@code Graphics} object to
    5.56 +     * render the content of the component.
    5.57 +     *
    5.58 +     * @param g the {@code Graphics} context in which to paint;
    5.59 +     * @param c the component being painted;
    5.60 +     * it can be safely cast to the {@code JLayer<V>}
    5.61 +     */
    5.62 +    @Override
    5.63 +    public void paint(Graphics g, JComponent c) {
    5.64 +        c.paint(g);
    5.65 +    }
    5.66 +
    5.67 +    /**
    5.68 +     * Dispatches {@code AWTEvent}s for {@code JLayer}
    5.69 +     * and <b>all it subcomponents</b> to this {@code LayerUI} instance.
    5.70 +     * <p>
    5.71 +     * To enable the {@code AWTEvent} of the particular type,
    5.72 +     * you call {@link javax.swing.JLayer#setLayerEventMask}
    5.73 +     * in {@link #installUI(javax.swing.JComponent)}
    5.74 +     * and set the layer event mask to {@code 0}
    5.75 +     * in {@link #uninstallUI(javax.swing.JComponent)} after that
    5.76 +     *
    5.77 +     * @param e the event to be dispatched
    5.78 +     * @param l the layer this LayerUI is set to
    5.79 +     *
    5.80 +     * @see JLayer#setLayerEventMask(long)
    5.81 +     * @see javax.swing.JLayer#getLayerEventMask()
    5.82 +     */
    5.83 +    public void eventDispatched(AWTEvent e, JLayer<? extends V> l){
    5.84 +    }
    5.85 +
    5.86 +    /**
    5.87 +     * Invoked when {@link javax.swing.JLayer#updateUI()} is called
    5.88 +     * by the {@code JLayer} this {@code LayerUI} is set to.
    5.89 +     *
    5.90 +     * @param l the {@code JLayer} which UI is updated
    5.91 +     */
    5.92 +    public void updateUI(JLayer<? extends V> l){
    5.93 +    }
    5.94 +
    5.95 +    /**
    5.96 +     * Configures the {@code JLayer} this {@code LayerUI} is set to.
    5.97 +     * The default implementation registers the {@code LayerUI}
    5.98 +     * as a property change listener for the passed {@code JLayer} component.
    5.99 +     *
   5.100 +     * @param c the {@code JLayer} component where this UI delegate is being installed
   5.101 +     */
   5.102 +    public void installUI(JComponent c) {
   5.103 +        addPropertyChangeListener((JLayer) c);
   5.104 +    }
   5.105 +
   5.106 +    /**
   5.107 +     * Reverses the configuration which was previously set
   5.108 +     * in the {@link #installUI(JComponent)} method.
   5.109 +     * The default implementation unregisters the property change listener
   5.110 +     * for the passed JLayer component.
   5.111 +     *
   5.112 +     * @param c the component from which this UI delegate is being removed.
   5.113 +     */
   5.114 +    public void uninstallUI(JComponent c) {
   5.115 +        removePropertyChangeListener((JLayer) c);
   5.116 +    }
   5.117 +
   5.118 +    /**
   5.119 +     * Adds a PropertyChangeListener to the listener list. The listener is
   5.120 +     * registered for all bound properties of this class.
   5.121 +     * <p/>
   5.122 +     * If {@code listener} is {@code null},
   5.123 +     * no exception is thrown and no action is performed.
   5.124 +     *
   5.125 +     * @param listener the property change listener to be added
   5.126 +     * @see #removePropertyChangeListener
   5.127 +     * @see #getPropertyChangeListeners
   5.128 +     * @see #addPropertyChangeListener(String, java.beans.PropertyChangeListener)
   5.129 +     */
   5.130 +    public void addPropertyChangeListener(PropertyChangeListener listener) {
   5.131 +        propertyChangeSupport.addPropertyChangeListener(listener);
   5.132 +    }
   5.133 +
   5.134 +    /**
   5.135 +     * Removes a PropertyChangeListener from the listener list. This method
   5.136 +     * should be used to remove PropertyChangeListeners that were registered
   5.137 +     * for all bound properties of this class.
   5.138 +     * <p/>
   5.139 +     * If {@code listener} is {@code null},
   5.140 +     * no exception is thrown and no action is performed.
   5.141 +     *
   5.142 +     * @param listener the PropertyChangeListener to be removed
   5.143 +     * @see #addPropertyChangeListener
   5.144 +     * @see #getPropertyChangeListeners
   5.145 +     * @see #removePropertyChangeListener(String, PropertyChangeListener)
   5.146 +     */
   5.147 +    public void removePropertyChangeListener(PropertyChangeListener listener) {
   5.148 +        propertyChangeSupport.removePropertyChangeListener(listener);
   5.149 +    }
   5.150 +
   5.151 +    /**
   5.152 +     * Returns an array of all the property change listeners
   5.153 +     * registered on this component.
   5.154 +     *
   5.155 +     * @return all of this ui's {@code PropertyChangeListener}s
   5.156 +     *         or an empty array if no property change
   5.157 +     *         listeners are currently registered
   5.158 +     * @see #addPropertyChangeListener
   5.159 +     * @see #removePropertyChangeListener
   5.160 +     * @see #getPropertyChangeListeners(String)
   5.161 +     */
   5.162 +    public PropertyChangeListener[] getPropertyChangeListeners() {
   5.163 +        return propertyChangeSupport.getPropertyChangeListeners();
   5.164 +    }
   5.165 +
   5.166 +    /**
   5.167 +     * Adds a PropertyChangeListener to the listener list for a specific
   5.168 +     * property.
   5.169 +     * <p/>
   5.170 +     * If {@code propertyName} or {@code listener} is {@code null},
   5.171 +     * no exception is thrown and no action is taken.
   5.172 +     *
   5.173 +     * @param propertyName one of the property names listed above
   5.174 +     * @param listener     the property change listener to be added
   5.175 +     * @see #removePropertyChangeListener(String, PropertyChangeListener)
   5.176 +     * @see #getPropertyChangeListeners(String)
   5.177 +     * @see #addPropertyChangeListener(String, PropertyChangeListener)
   5.178 +     */
   5.179 +    public void addPropertyChangeListener(String propertyName,
   5.180 +                                          PropertyChangeListener listener) {
   5.181 +        propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
   5.182 +    }
   5.183 +
   5.184 +    /**
   5.185 +     * Removes a {@code PropertyChangeListener} from the listener
   5.186 +     * list for a specific property. This method should be used to remove
   5.187 +     * {@code PropertyChangeListener}s
   5.188 +     * that were registered for a specific bound property.
   5.189 +     * <p/>
   5.190 +     * If {@code propertyName} or {@code listener} is {@code null},
   5.191 +     * no exception is thrown and no action is taken.
   5.192 +     *
   5.193 +     * @param propertyName a valid property name
   5.194 +     * @param listener     the PropertyChangeListener to be removed
   5.195 +     * @see #addPropertyChangeListener(String, PropertyChangeListener)
   5.196 +     * @see #getPropertyChangeListeners(String)
   5.197 +     * @see #removePropertyChangeListener(PropertyChangeListener)
   5.198 +     */
   5.199 +    public void removePropertyChangeListener(String propertyName,
   5.200 +                                             PropertyChangeListener listener) {
   5.201 +        propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
   5.202 +    }
   5.203 +
   5.204 +    /**
   5.205 +     * Returns an array of all the listeners which have been associated
   5.206 +     * with the named property.
   5.207 +     *
   5.208 +     * @return all of the {@code PropertyChangeListener}s associated with
   5.209 +     *         the named property; if no such listeners have been added or
   5.210 +     *         if {@code propertyName} is {@code null}, an empty
   5.211 +     *         array is returned
   5.212 +     * @see #addPropertyChangeListener(String, PropertyChangeListener)
   5.213 +     * @see #removePropertyChangeListener(String, PropertyChangeListener)
   5.214 +     * @see #getPropertyChangeListeners
   5.215 +     */
   5.216 +    public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
   5.217 +        return propertyChangeSupport.getPropertyChangeListeners(propertyName);
   5.218 +    }
   5.219 +
   5.220 +    /**
   5.221 +     * Support for reporting bound property changes for Object properties.
   5.222 +     * This method can be called when a bound property has changed and it will
   5.223 +     * send the appropriate PropertyChangeEvent to any registered
   5.224 +     * PropertyChangeListeners.
   5.225 +     *
   5.226 +     * @param propertyName the property whose value has changed
   5.227 +     * @param oldValue     the property's previous value
   5.228 +     * @param newValue     the property's new value
   5.229 +     */
   5.230 +    protected void firePropertyChange(String propertyName,
   5.231 +                                      Object oldValue, Object newValue) {
   5.232 +        propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
   5.233 +    }
   5.234 +
   5.235 +    /**
   5.236 +     * Notifies the {@code LayerUI} when any of its property are changed
   5.237 +     * and enables updating every {@code JLayer} this {@code LayerUI} instance is set to.
   5.238 +     *
   5.239 +     * @param evt the PropertyChangeEvent generated by this {@code LayerUI}
   5.240 +     * @param l the {@code JLayer} this LayerUI is set to
   5.241 +     */
   5.242 +    public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) {
   5.243 +    }
   5.244 +
   5.245 +    /**
   5.246 +     * Returns the preferred size of the viewport for a view component.
   5.247 +     *
   5.248 +     * @return the preferred size of the viewport for a view component
   5.249 +     * @see Scrollable#getPreferredScrollableViewportSize()
   5.250 +     */
   5.251 +    public Dimension getPreferredScrollableViewportSize(JLayer<? extends V> l) {
   5.252 +        if (l.getView() instanceof Scrollable) {
   5.253 +            return ((Scrollable)l.getView()).getPreferredScrollableViewportSize();
   5.254 +        }
   5.255 +        return l.getPreferredSize();
   5.256 +    }
   5.257 +
   5.258 +    /**
   5.259 +     * Returns a scroll increment, which is required for components
   5.260 +     * that display logical rows or columns in order to completely expose
   5.261 +     * one block of rows or columns, depending on the value of orientation.
   5.262 +     *
   5.263 +     * @return the "block" increment for scrolling in the specified direction
   5.264 +     * @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int)
   5.265 +     */
   5.266 +     public int getScrollableBlockIncrement(JLayer<? extends V> l,
   5.267 +                                           Rectangle visibleRect,
   5.268 +                                           int orientation, int direction) {
   5.269 +        if (l.getView() instanceof Scrollable) {
   5.270 +            return ((Scrollable)l.getView()).getScrollableBlockIncrement(
   5.271 +                    visibleRect,orientation, direction);
   5.272 +        }
   5.273 +        return (orientation == SwingConstants.VERTICAL) ? visibleRect.height :
   5.274 +            visibleRect.width;
   5.275 +    }
   5.276 +
   5.277 +    /**
   5.278 +     * Returns {@code false} to indicate that the height of the viewport does not
   5.279 +     * determine the height of the layer, unless the preferred height
   5.280 +     * of the layer is smaller than the height of the viewport.
   5.281 +     *
   5.282 +     * @return whether the layer should track the height of the viewport
   5.283 +     * @see Scrollable#getScrollableTracksViewportHeight()
   5.284 +     */
   5.285 +    public boolean getScrollableTracksViewportHeight(JLayer<? extends V> l) {
   5.286 +        if (l.getView() instanceof Scrollable) {
   5.287 +            return ((Scrollable)l.getView()).getScrollableTracksViewportHeight();
   5.288 +        }
   5.289 +        if (l.getParent() instanceof JViewport) {
   5.290 +            return (((JViewport)l.getParent()).getHeight() > l.getPreferredSize().height);
   5.291 +        }
   5.292 +        return false;
   5.293 +    }
   5.294 +
   5.295 +    /**
   5.296 +     * Returns {@code false} to indicate that the width of the viewport does not
   5.297 +     * determine the width of the layer, unless the preferred width
   5.298 +     * of the layer is smaller than the width of the viewport.
   5.299 +     *
   5.300 +     * @return whether the layer should track the width of the viewport
   5.301 +     * @see Scrollable
   5.302 +     * @see LayerUI#getScrollableTracksViewportWidth(JLayer)
   5.303 +     */
   5.304 +    public boolean getScrollableTracksViewportWidth(JLayer<? extends V> l) {
   5.305 +        if (l.getView() instanceof Scrollable) {
   5.306 +            return ((Scrollable)l.getView()).getScrollableTracksViewportWidth();
   5.307 +        }
   5.308 +        if (l.getParent() instanceof JViewport) {
   5.309 +            return (((JViewport)l.getParent()).getWidth() > l.getPreferredSize().width);
   5.310 +        }
   5.311 +        return false;
   5.312 +    }
   5.313 +
   5.314 +    /**
   5.315 +     * Returns a scroll increment, which is required for components
   5.316 +     * that display logical rows or columns in order to completely expose
   5.317 +     * one new row or column, depending on the value of orientation.
   5.318 +     * Ideally, components should handle a partially exposed row or column
   5.319 +     * by returning the distance required to completely expose the item.
   5.320 +     * <p>
   5.321 +     * Scrolling containers, like JScrollPane, will use this method
   5.322 +     * each time the user requests a unit scroll.
   5.323 +     *
   5.324 +     * @return The "unit" increment for scrolling in the specified direction.
   5.325 +     *         This value should always be positive.
   5.326 +     * @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
   5.327 +     */
   5.328 +    public int getScrollableUnitIncrement(JLayer<? extends V> l,
   5.329 +                                          Rectangle visibleRect,
   5.330 +                                          int orientation, int direction) {
   5.331 +        if (l.getView() instanceof Scrollable) {
   5.332 +            return ((Scrollable)l.getView()).getScrollableUnitIncrement(
   5.333 +                    visibleRect, orientation, direction);
   5.334 +        }
   5.335 +        return 1;
   5.336 +    }
   5.337 +
   5.338 +    /**
   5.339 +     * If the {@code JLayer}'s view component is not {@code null},
   5.340 +     * this calls the view's {@code getBaseline()} method.
   5.341 +     * Otherwise, the default implementation is called.
   5.342 +     *
   5.343 +     * @param c {@code JLayer} to return baseline resize behavior for
   5.344 +     * @param width the width to get the baseline for
   5.345 +     * @param height the height to get the baseline for
   5.346 +     * @return baseline or a value &lt; 0 indicating there is no reasonable
   5.347 +     *                  baseline
   5.348 +     */
   5.349 +    public int getBaseline(JComponent c, int width, int height) {
   5.350 +        JLayer l = (JLayer) c;
   5.351 +        if (l.getView() != null) {
   5.352 +            return l.getView().getBaseline(width, height);
   5.353 +        }
   5.354 +        return super.getBaseline(c, width, height);
   5.355 +     }
   5.356 +
   5.357 +    /**
   5.358 +     * If the {@code JLayer}'s view component is not {@code null},
   5.359 +     * this calls the view's {@code getBaselineResizeBehavior()} method.
   5.360 +     * Otherwise, the default implementation is called.
   5.361 +     *
   5.362 +     * @param c {@code JLayer} to return baseline resize behavior for
   5.363 +     * @return an enum indicating how the baseline changes as the component
   5.364 +     *         size changes
   5.365 +     */
   5.366 +    public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c) {
   5.367 +        JLayer l = (JLayer) c;
   5.368 +        if (l.getView() != null) {
   5.369 +            return l.getView().getBaselineResizeBehavior();
   5.370 +        }
   5.371 +        return super.getBaselineResizeBehavior(c);
   5.372 +    }
   5.373 +}
   5.374 \ No newline at end of file
     6.1 --- a/src/share/classes/javax/swing/text/GlyphView.java	Fri Aug 14 08:51:56 2009 -0700
     6.2 +++ b/src/share/classes/javax/swing/text/GlyphView.java	Tue Aug 18 23:40:15 2009 -0700
     6.3 @@ -540,30 +540,7 @@
     6.4       */
     6.5      @Override
     6.6      public float getMinimumSpan(int axis) {
     6.7 -        switch (axis) {
     6.8 -        case View.X_AXIS:
     6.9 -            if (minimumSpan < 0) {
    6.10 -                minimumSpan = 0;
    6.11 -                int p0 = getStartOffset();
    6.12 -                int p1 = getEndOffset();
    6.13 -                while (p1 > p0) {
    6.14 -                    int breakSpot = getBreakSpot(p0, p1);
    6.15 -                    if (breakSpot == BreakIterator.DONE) {
    6.16 -                        // the rest of the view is non-breakable
    6.17 -                        breakSpot = p0;
    6.18 -                    }
    6.19 -                    minimumSpan = Math.max(minimumSpan,
    6.20 -                            getPartialSpan(breakSpot, p1));
    6.21 -                    // Note: getBreakSpot returns the *last* breakspot
    6.22 -                    p1 = breakSpot - 1;
    6.23 -                }
    6.24 -            }
    6.25 -            return minimumSpan;
    6.26 -        case View.Y_AXIS:
    6.27 -            return super.getMinimumSpan(axis);
    6.28 -        default:
    6.29 -            throw new IllegalArgumentException("Invalid axis: " + axis);
    6.30 -        }
    6.31 +        return super.getMinimumSpan(axis);
    6.32      }
    6.33  
    6.34      /**
     7.1 --- a/src/share/classes/javax/swing/text/ParagraphView.java	Fri Aug 14 08:51:56 2009 -0700
     7.2 +++ b/src/share/classes/javax/swing/text/ParagraphView.java	Tue Aug 18 23:40:15 2009 -0700
     7.3 @@ -721,35 +721,7 @@
     7.4      @Override
     7.5      protected SizeRequirements calculateMinorAxisRequirements(int axis,
     7.6                                                          SizeRequirements r) {
     7.7 -        r = super.calculateMinorAxisRequirements(axis, r);
     7.8 -
     7.9 -        float min = 0;
    7.10 -        float glue = 0;
    7.11 -        int n = getLayoutViewCount();
    7.12 -        for (int i = 0; i < n; i++) {
    7.13 -            View v = getLayoutView(i);
    7.14 -            float span = v.getMinimumSpan(axis);
    7.15 -            if (v.getBreakWeight(axis, 0, v.getMaximumSpan(axis))
    7.16 -                                                        > View.BadBreakWeight) {
    7.17 -                // find the longest non-breakable fragments at the view edges
    7.18 -                int p0 = v.getStartOffset();
    7.19 -                int p1 = v.getEndOffset();
    7.20 -                float start = findEdgeSpan(v, axis, p0, p0, p1);
    7.21 -                float end = findEdgeSpan(v, axis, p1, p0, p1);
    7.22 -                glue += start;
    7.23 -                min = Math.max(min, Math.max(span, glue));
    7.24 -                glue = end;
    7.25 -            } else {
    7.26 -                // non-breakable view
    7.27 -                glue += span;
    7.28 -                min = Math.max(min, glue);
    7.29 -            }
    7.30 -        }
    7.31 -        r.minimum = Math.max(r.minimum, (int) min);
    7.32 -        r.preferred = Math.max(r.minimum,  r.preferred);
    7.33 -        r.maximum = Math.max(r.preferred, r.maximum);
    7.34 -
    7.35 -        return r;
    7.36 +        return super.calculateMinorAxisRequirements(axis, r);
    7.37      }
    7.38  
    7.39      /**
     8.1 --- a/src/share/classes/javax/swing/text/WrappedPlainView.java	Fri Aug 14 08:51:56 2009 -0700
     8.2 +++ b/src/share/classes/javax/swing/text/WrappedPlainView.java	Tue Aug 18 23:40:15 2009 -0700
     8.3 @@ -327,13 +327,45 @@
     8.4      /**
     8.5       * Return reasonable default values for the view dimensions.  The standard
     8.6       * text terminal size 80x24 is pretty suitable for the wrapped plain view.
     8.7 +     *
     8.8 +     * The size should not be larger than the component housing the view's
     8.9 +     * container.
    8.10       */
    8.11      private float getDefaultSpan(int axis) {
    8.12 +         Container host = getContainer();
    8.13 +         Component parent = null;
    8.14 +
    8.15 +         if (host != null) {
    8.16 +            parent = host.getParent();
    8.17 +         }
    8.18 +
    8.19           switch (axis) {
    8.20              case View.X_AXIS:
    8.21 -                return 80 * metrics.getWidths()['M'];
    8.22 +               int defaultWidth = 80 * metrics.getWidths()['M'];
    8.23 +               int parentWidth = 0;
    8.24 +
    8.25 +               if (parent != null) {
    8.26 +                  parentWidth = parent.getWidth();
    8.27 +               }
    8.28 +
    8.29 +               if (defaultWidth > parentWidth) {
    8.30 +                 return parentWidth;
    8.31 +               }
    8.32 +               return defaultWidth;
    8.33 +
    8.34              case View.Y_AXIS:
    8.35 -                return 24 * metrics.getHeight();
    8.36 +               int defaultHeight = 24 * metrics.getHeight();
    8.37 +               int parentHeight = 0;
    8.38 +
    8.39 +               if (parent != null) {
    8.40 +                  parentHeight = parent.getHeight();
    8.41 +               }
    8.42 +
    8.43 +               if (defaultHeight > parentHeight) {
    8.44 +                 return parentHeight;
    8.45 +               }
    8.46 +               return defaultHeight;
    8.47 +
    8.48              default:
    8.49                  throw new IllegalArgumentException("Invalid axis: " + axis);
    8.50          }
     9.1 --- a/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Fri Aug 14 08:51:56 2009 -0700
     9.2 +++ b/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Tue Aug 18 23:40:15 2009 -0700
     9.3 @@ -73,12 +73,7 @@
     9.4  
     9.5      private static native void initIDs();
     9.6  
     9.7 -    private static final boolean is98;
     9.8 -
     9.9      static {
    9.10 -        String osName = System.getProperty("os.name");
    9.11 -        is98 = (osName != null && osName.startsWith("Windows 98"));
    9.12 -
    9.13          initIDs();
    9.14      }
    9.15  
    9.16 @@ -305,7 +300,6 @@
    9.17              }, RuntimeException.class)
    9.18          );
    9.19          this.disposer.relativePIDL = relativePIDL;
    9.20 -        getAbsolutePath();
    9.21          sun.java2d.Disposer.addRecord(this, disposer);
    9.22      }
    9.23  
    9.24 @@ -616,11 +610,8 @@
    9.25      public boolean isDirectory() {
    9.26          if (isDir == null) {
    9.27              // Folders with SFGAO_BROWSABLE have "shell extension" handlers and are
    9.28 -            // not traversable in JFileChooser. An exception is "My Documents" on
    9.29 -            // Windows 98.
    9.30 -            if (hasAttribute(ATTRIB_FOLDER)
    9.31 -                && (!hasAttribute(ATTRIB_BROWSABLE) ||
    9.32 -                    (is98 && equals(Win32ShellFolderManager2.getPersonal())))) {
    9.33 +            // not traversable in JFileChooser.
    9.34 +            if (hasAttribute(ATTRIB_FOLDER) && !hasAttribute(ATTRIB_BROWSABLE)) {
    9.35                  isDir = Boolean.TRUE;
    9.36              } else if (isLink()) {
    9.37                  ShellFolder linkLocation = getLinkLocation(false);
    10.1 --- a/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Fri Aug 14 08:51:56 2009 -0700
    10.2 +++ b/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Tue Aug 18 23:40:15 2009 -0700
    10.3 @@ -105,9 +105,11 @@
    10.4      private static Win32ShellFolder2 network;
    10.5      private static Win32ShellFolder2 personal;
    10.6  
    10.7 -    private static String osVersion = System.getProperty("os.version");
    10.8 -    private static final boolean useShell32Icons =
    10.9 -                        (osVersion != null && osVersion.compareTo("5.1") >= 0);
   10.10 +    private static final boolean USE_SHELL32_ICONS = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
   10.11 +        public Boolean run() {
   10.12 +            return OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0;
   10.13 +        }
   10.14 +    });
   10.15  
   10.16      static Win32ShellFolder2 getDesktop() {
   10.17          if (desktop == null) {
   10.18 @@ -307,15 +309,15 @@
   10.19                  i = Integer.parseInt(name);
   10.20              } catch (NumberFormatException ex) {
   10.21                  if (name.equals("ListView")) {
   10.22 -                    i = (useShell32Icons) ? 21 : 2;
   10.23 +                    i = (USE_SHELL32_ICONS) ? 21 : 2;
   10.24                  } else if (name.equals("DetailsView")) {
   10.25 -                    i = (useShell32Icons) ? 23 : 3;
   10.26 +                    i = (USE_SHELL32_ICONS) ? 23 : 3;
   10.27                  } else if (name.equals("UpFolder")) {
   10.28 -                    i = (useShell32Icons) ? 28 : 8;
   10.29 +                    i = (USE_SHELL32_ICONS) ? 28 : 8;
   10.30                  } else if (name.equals("NewFolder")) {
   10.31 -                    i = (useShell32Icons) ? 31 : 11;
   10.32 +                    i = (USE_SHELL32_ICONS) ? 31 : 11;
   10.33                  } else if (name.equals("ViewMenu")) {
   10.34 -                    i = (useShell32Icons) ? 21 : 2;
   10.35 +                    i = (USE_SHELL32_ICONS) ? 21 : 2;
   10.36                  }
   10.37              }
   10.38              if (i >= 0) {
   10.39 @@ -352,11 +354,16 @@
   10.40       * Does <code>dir</code> represent a "computer" such as a node on the network, or
   10.41       * "My Computer" on the desktop.
   10.42       */
   10.43 -    public boolean isComputerNode(File dir) {
   10.44 +    public boolean isComputerNode(final File dir) {
   10.45          if (dir != null && dir == getDrives()) {
   10.46              return true;
   10.47          } else {
   10.48 -            String path = dir.getAbsolutePath();
   10.49 +            String path = AccessController.doPrivileged(new PrivilegedAction<String>() {
   10.50 +                public String run() {
   10.51 +                    return dir.getAbsolutePath();
   10.52 +                }
   10.53 +            });
   10.54 +
   10.55              return (path.startsWith("\\\\") && path.indexOf("\\", 2) < 0);      //Network path
   10.56          }
   10.57      }
   10.58 @@ -501,7 +508,7 @@
   10.59                  // thread, we don't need to delegate the task
   10.60                  return task.call();
   10.61              } else {
   10.62 -                Future<T> future;
   10.63 +                final Future<T> future;
   10.64  
   10.65                  try {
   10.66                      future = submit(task);
   10.67 @@ -512,7 +519,13 @@
   10.68                  try {
   10.69                      return future.get();
   10.70                  } catch (InterruptedException e) {
   10.71 -                    future.cancel(true);
   10.72 +                    AccessController.doPrivileged(new PrivilegedAction<Void>() {
   10.73 +                        public Void run() {
   10.74 +                            future.cancel(true);
   10.75 +
   10.76 +                            return null;
   10.77 +                        }
   10.78 +                    });
   10.79  
   10.80                      throw e;
   10.81                  } catch (ExecutionException e) {
    11.1 --- a/src/windows/native/sun/windows/awt_Toolkit.cpp	Fri Aug 14 08:51:56 2009 -0700
    11.2 +++ b/src/windows/native/sun/windows/awt_Toolkit.cpp	Tue Aug 18 23:40:15 2009 -0700
    11.3 @@ -1596,18 +1596,18 @@
    11.4  }
    11.5  
    11.6  JNIEnv* AwtToolkit::m_env;
    11.7 -HANDLE AwtToolkit::m_thread;
    11.8 +DWORD AwtToolkit::m_threadId;
    11.9  
   11.10  void AwtToolkit::SetEnv(JNIEnv *env) {
   11.11      if (m_env != NULL) { // If already cashed (by means of embeddedInit() call).
   11.12          return;
   11.13      }
   11.14 -    m_thread = GetCurrentThread();
   11.15 +    m_threadId = GetCurrentThreadId();
   11.16      m_env = env;
   11.17  }
   11.18  
   11.19  JNIEnv* AwtToolkit::GetEnv() {
   11.20 -    return (m_env == NULL || m_thread != GetCurrentThread()) ?
   11.21 +    return (m_env == NULL || m_threadId != GetCurrentThreadId()) ?
   11.22          (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_2) : m_env;
   11.23  }
   11.24  
    12.1 --- a/src/windows/native/sun/windows/awt_Toolkit.h	Fri Aug 14 08:51:56 2009 -0700
    12.2 +++ b/src/windows/native/sun/windows/awt_Toolkit.h	Tue Aug 18 23:40:15 2009 -0700
    12.3 @@ -442,7 +442,7 @@
    12.4  
    12.5   private:
    12.6      static JNIEnv *m_env;
    12.7 -    static HANDLE m_thread;
    12.8 +    static DWORD m_threadId;
    12.9   public:
   12.10      static void SetEnv(JNIEnv *env);
   12.11      static JNIEnv* GetEnv();
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/java/beans/Introspector/Test6868189.java	Tue Aug 18 23:40:15 2009 -0700
    13.3 @@ -0,0 +1,66 @@
    13.4 +/*
    13.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   13.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   13.24 + * have any questions.
   13.25 + */
   13.26 +
   13.27 +/*
   13.28 + * @test
   13.29 + * @bug 6868189
   13.30 + * @summary Tests custom BeanInfo in the same package
   13.31 + * @author Sergey Malenkov
   13.32 + */
   13.33 +
   13.34 +import java.beans.IntrospectionException;
   13.35 +import java.beans.Introspector;
   13.36 +import java.beans.PropertyDescriptor;
   13.37 +import java.beans.SimpleBeanInfo;
   13.38 +
   13.39 +public class Test6868189 {
   13.40 +
   13.41 +    private static final String PROPERTY = "$?"; // NON-NLS: the property name
   13.42 +    private static final String GETTER = "name"; // NON-NLS: the method name
   13.43 +    private static final String SETTER = null;
   13.44 +
   13.45 +    public static void main(String[] args) throws IntrospectionException {
   13.46 +        PropertyDescriptor[] pds = Introspector.getBeanInfo(Enumeration.class).getPropertyDescriptors();
   13.47 +        if ((pds.length != 1)|| !PROPERTY.equals(pds[0].getName())){
   13.48 +            throw new Error("unexpected property");
   13.49 +        }
   13.50 +    }
   13.51 +
   13.52 +    public enum Enumeration {
   13.53 +        FIRST, SECOND
   13.54 +    }
   13.55 +
   13.56 +    public static class EnumerationBeanInfo extends SimpleBeanInfo {
   13.57 +        @Override
   13.58 +        public PropertyDescriptor[] getPropertyDescriptors() {
   13.59 +            try {
   13.60 +                return new PropertyDescriptor[] {
   13.61 +                        new PropertyDescriptor(PROPERTY, Enumeration.class, GETTER, SETTER)
   13.62 +                };
   13.63 +            }
   13.64 +            catch (IntrospectionException exception) {
   13.65 +                throw new Error("unexpected exception", exception);
   13.66 +            }
   13.67 +        }
   13.68 +    }
   13.69 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/javax/swing/JInternalFrame/Test6325652.java	Tue Aug 18 23:40:15 2009 -0700
    14.3 @@ -0,0 +1,105 @@
    14.4 +/*
    14.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   14.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   14.24 + * have any questions.
   14.25 + */
   14.26 +
   14.27 +/*
   14.28 + * @test
   14.29 + * @bug 6325652
   14.30 + * @summary Tests keyboard shortcuts
   14.31 + * @author Sergey Malenkov
   14.32 + * @library ..
   14.33 + */
   14.34 +
   14.35 +import java.awt.AWTException;
   14.36 +import java.awt.Robot;
   14.37 +import java.awt.event.KeyEvent;
   14.38 +import java.beans.PropertyVetoException;
   14.39 +import javax.swing.JDesktopPane;
   14.40 +import javax.swing.JFrame;
   14.41 +import javax.swing.JInternalFrame;
   14.42 +import javax.swing.JTextArea;
   14.43 +
   14.44 +public class Test6325652 {
   14.45 +
   14.46 +    private static final int WIDTH = 300;
   14.47 +    private static final int HEIGHT = 300;
   14.48 +
   14.49 +    public static void main(String[] args) throws Throwable {
   14.50 +        SwingTest.start(Test6325652.class);
   14.51 +    }
   14.52 +
   14.53 +    private static Robot robot;
   14.54 +    private JInternalFrame internal;
   14.55 +
   14.56 +    public Test6325652(JFrame frame) {
   14.57 +        JDesktopPane desktop = new JDesktopPane();
   14.58 +        desktop.add(create(0));
   14.59 +        desktop.add(this.internal = create(1));
   14.60 +        frame.add(desktop);
   14.61 +    }
   14.62 +
   14.63 +    public void select() throws PropertyVetoException {
   14.64 +        this.internal.setSelected(true);
   14.65 +    }
   14.66 +
   14.67 +    public static void stepFirst() throws AWTException {
   14.68 +        robot = new Robot(); // initialize shared static field first time
   14.69 +        click(KeyEvent.VK_CONTROL, KeyEvent.VK_F9); // iconify internal frame
   14.70 +    }
   14.71 +
   14.72 +    public void stepFirstValidate() {
   14.73 +        if (!this.internal.isIcon()) {
   14.74 +            throw new Error("frame should be an icon");
   14.75 +        }
   14.76 +    }
   14.77 +
   14.78 +    public static void stepSecond() {
   14.79 +        click(KeyEvent.VK_CONTROL, KeyEvent.VK_F6); // navigate to the icon
   14.80 +        click(KeyEvent.VK_CONTROL, KeyEvent.VK_F5); // restore the icon
   14.81 +    }
   14.82 +
   14.83 +    public void stepSecondValidate() {
   14.84 +        if (this.internal.isIcon()) {
   14.85 +            throw new Error("frame should not be an icon");
   14.86 +        }
   14.87 +    }
   14.88 +
   14.89 +    private static void click(int... keys) {
   14.90 +        for (int key : keys) {
   14.91 +            robot.keyPress(key);
   14.92 +        }
   14.93 +        for (int key : keys) {
   14.94 +            robot.keyRelease(key);
   14.95 +        }
   14.96 +    }
   14.97 +
   14.98 +    private static JInternalFrame create(int index) {
   14.99 +        String text = "test" + index; // NON-NLS: frame identification
  14.100 +        index = index * 3 + 1;
  14.101 +
  14.102 +        JInternalFrame internal = new JInternalFrame(text, true, true, true, true);
  14.103 +        internal.getContentPane().add(new JTextArea(text));
  14.104 +        internal.setBounds(10 * index, 10 * index, WIDTH, HEIGHT);
  14.105 +        internal.setVisible(true);
  14.106 +        return internal;
  14.107 +    }
  14.108 +}
    15.1 --- a/test/javax/swing/JInternalFrame/Test6505027.java	Fri Aug 14 08:51:56 2009 -0700
    15.2 +++ b/test/javax/swing/JInternalFrame/Test6505027.java	Tue Aug 18 23:40:15 2009 -0700
    15.3 @@ -26,6 +26,7 @@
    15.4   * @bug 6505027
    15.5   * @summary Tests focus problem inside internal frame
    15.6   * @author Sergey Malenkov
    15.7 + * @library ..
    15.8   */
    15.9  
   15.10  import java.awt.AWTException;
   15.11 @@ -45,11 +46,10 @@
   15.12  import javax.swing.JTable;
   15.13  import javax.swing.JTextField;
   15.14  import javax.swing.SwingUtilities;
   15.15 -import javax.swing.WindowConstants;
   15.16  import javax.swing.table.DefaultTableModel;
   15.17  import javax.swing.table.TableColumn;
   15.18  
   15.19 -public class Test6505027 implements Runnable {
   15.20 +public class Test6505027 {
   15.21  
   15.22      private static final boolean INTERNAL = true;
   15.23      private static final boolean TERMINATE = true;
   15.24 @@ -57,80 +57,53 @@
   15.25      private static final int WIDTH = 450;
   15.26      private static final int HEIGHT = 200;
   15.27      private static final int OFFSET = 10;
   15.28 -    private static final long PAUSE = 2048L;
   15.29  
   15.30 -    private static final String[] COLUMNS = { "Size", "Shape" }; // NON-NLS
   15.31 -    private static final String[] ITEMS = { "a", "b", "c", "d" }; // NON-NLS
   15.32 -    private static final String KEY = "terminateEditOnFocusLost"; // NON-NLS
   15.33 +    private static final String[] COLUMNS = { "Size", "Shape" }; // NON-NLS: column names
   15.34 +    private static final String[] ITEMS = { "a", "b", "c", "d" }; // NON-NLS: combobox content
   15.35 +    private static final String KEY = "terminateEditOnFocusLost"; // NON-NLS: property name
   15.36  
   15.37 -    public static void main(String[] args) {
   15.38 -        SwingUtilities.invokeLater(new Test6505027());
   15.39 +    public static void main(String[] args) throws Throwable {
   15.40 +        SwingTest.start(Test6505027.class);
   15.41 +    }
   15.42  
   15.43 -        Component component = null;
   15.44 -        while (component == null) {
   15.45 -            try {
   15.46 -                Thread.sleep(PAUSE);
   15.47 -            }
   15.48 -            catch (InterruptedException exception) {
   15.49 -                // ignore interrupted exception
   15.50 -            }
   15.51 -            component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
   15.52 +    private final JTable table = new JTable(new DefaultTableModel(COLUMNS, 2));
   15.53 +
   15.54 +    public Test6505027(JFrame main) {
   15.55 +        Container container = main;
   15.56 +        if (INTERNAL) {
   15.57 +            JInternalFrame frame = new JInternalFrame();
   15.58 +            frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
   15.59 +            frame.setVisible(true);
   15.60 +
   15.61 +            JDesktopPane desktop = new JDesktopPane();
   15.62 +            desktop.add(frame, new Integer(1));
   15.63 +
   15.64 +            container.add(desktop);
   15.65 +            container = frame;
   15.66          }
   15.67 +        if (TERMINATE) {
   15.68 +            this.table.putClientProperty(KEY, Boolean.TRUE);
   15.69 +        }
   15.70 +        TableColumn column = this.table.getColumn(COLUMNS[1]);
   15.71 +        column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));
   15.72 +
   15.73 +        container.add(BorderLayout.NORTH, new JTextField());
   15.74 +        container.add(BorderLayout.CENTER, new JScrollPane(this.table));
   15.75 +    }
   15.76 +
   15.77 +    public void press() throws AWTException {
   15.78 +        Point point = this.table.getCellRect(1, 1, false).getLocation();
   15.79 +        SwingUtilities.convertPointToScreen(point, this.table);
   15.80 +
   15.81 +        Robot robot = new Robot();
   15.82 +        robot.mouseMove(point.x + 1, point.y + 1);
   15.83 +        robot.mousePress(InputEvent.BUTTON1_MASK);
   15.84 +    }
   15.85 +
   15.86 +    public static void validate() {
   15.87 +        Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
   15.88          if (!component.getClass().equals(JComboBox.class)) {
   15.89              throw new Error("unexpected focus owner: " + component);
   15.90          }
   15.91 -        SwingUtilities.getWindowAncestor(component).dispose();
   15.92 -    }
   15.93 -
   15.94 -    private JTable table;
   15.95 -    private Point point;
   15.96 -
   15.97 -    public void run() {
   15.98 -        if (this.table == null) {
   15.99 -            JFrame main = new JFrame();
  15.100 -            main.setSize(WIDTH + OFFSET * 3, HEIGHT + OFFSET * 5);
  15.101 -            main.setLocationRelativeTo(null);
  15.102 -            main.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  15.103 -            main.setVisible(true);
  15.104 -
  15.105 -            Container container = main;
  15.106 -            if (INTERNAL) {
  15.107 -                JInternalFrame frame = new JInternalFrame();
  15.108 -                frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
  15.109 -                frame.setVisible(true);
  15.110 -
  15.111 -                JDesktopPane desktop = new JDesktopPane();
  15.112 -                desktop.add(frame, new Integer(1));
  15.113 -
  15.114 -                container.add(desktop);
  15.115 -                container = frame;
  15.116 -            }
  15.117 -            this.table = new JTable(new DefaultTableModel(COLUMNS, 2));
  15.118 -            if (TERMINATE) {
  15.119 -                this.table.putClientProperty(KEY, Boolean.TRUE);
  15.120 -            }
  15.121 -            TableColumn column = this.table.getColumn(COLUMNS[1]);
  15.122 -            column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));
  15.123 -
  15.124 -            container.add(BorderLayout.NORTH, new JTextField());
  15.125 -            container.add(BorderLayout.CENTER, new JScrollPane(this.table));
  15.126 -
  15.127 -            SwingUtilities.invokeLater(this);
  15.128 -        }
  15.129 -        else if (this.point == null) {
  15.130 -            this.point = this.table.getCellRect(1, 1, false).getLocation();
  15.131 -            SwingUtilities.convertPointToScreen(this.point, this.table);
  15.132 -            SwingUtilities.invokeLater(this);
  15.133 -        }
  15.134 -        else {
  15.135 -            try {
  15.136 -                Robot robot = new Robot();
  15.137 -                robot.mouseMove(this.point.x + 1, this.point.y + 1);
  15.138 -                robot.mousePress(InputEvent.BUTTON1_MASK);
  15.139 -            }
  15.140 -            catch (AWTException exception) {
  15.141 -                throw new Error("unexpected exception", exception);
  15.142 -            }
  15.143 -        }
  15.144      }
  15.145  }
    16.1 --- a/test/javax/swing/JInternalFrame/Test6802868.java	Fri Aug 14 08:51:56 2009 -0700
    16.2 +++ b/test/javax/swing/JInternalFrame/Test6802868.java	Tue Aug 18 23:40:15 2009 -0700
    16.3 @@ -26,83 +26,73 @@
    16.4   * @bug 6802868
    16.5   * @summary JInternalFrame is not maximized when maximized parent frame
    16.6   * @author Alexander Potochkin
    16.7 + * @library ..
    16.8   */
    16.9  
   16.10 -import sun.awt.SunToolkit;
   16.11 -
   16.12  import java.awt.Dimension;
   16.13  import java.awt.Point;
   16.14 -import java.awt.Robot;
   16.15 -import java.awt.Toolkit;
   16.16  import java.beans.PropertyVetoException;
   16.17  import javax.swing.JDesktopPane;
   16.18  import javax.swing.JFrame;
   16.19  import javax.swing.JInternalFrame;
   16.20 -import javax.swing.SwingUtilities;
   16.21  
   16.22  public class Test6802868 {
   16.23 -    static JInternalFrame jif;
   16.24 -    static JFrame frame;
   16.25 -    static Dimension size;
   16.26 -    static Point location;
   16.27  
   16.28 -    public static void main(String[] args) throws Exception {
   16.29 -        Robot robot = new Robot();
   16.30 -        robot.setAutoDelay(20);
   16.31 -        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   16.32 +    public static void main(String[] args) throws Throwable {
   16.33 +        SwingTest.start(Test6802868.class);
   16.34 +    }
   16.35  
   16.36 -        SwingUtilities.invokeAndWait(new Runnable() {
   16.37 -            public void run() {
   16.38 -                frame = new JFrame();
   16.39 -                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   16.40 +    private final JFrame frame;
   16.41 +    private final JInternalFrame internal;
   16.42 +    private Dimension size;
   16.43 +    private Point location;
   16.44  
   16.45 -                JDesktopPane jdp = new JDesktopPane();
   16.46 -                frame.getContentPane().add(jdp);
   16.47 +    public Test6802868(JFrame frame) {
   16.48 +        JDesktopPane desktop = new JDesktopPane();
   16.49  
   16.50 -                jif = new JInternalFrame("Title", true, true, true, true);
   16.51 -                jdp.add(jif);
   16.52 -                jif.setVisible(true);
   16.53 +        this.frame = frame;
   16.54 +        this.frame.add(desktop);
   16.55  
   16.56 -                frame.setSize(200, 200);
   16.57 -                frame.setLocationRelativeTo(null);
   16.58 -                frame.setVisible(true);
   16.59 +        this.internal = new JInternalFrame(getClass().getName(), true, true, true, true);
   16.60 +        this.internal.setVisible(true);
   16.61  
   16.62 -                try {
   16.63 -                    jif.setMaximum(true);
   16.64 -                } catch (Exception e) {
   16.65 -                    e.printStackTrace();
   16.66 -                }
   16.67 -            }
   16.68 -        });
   16.69 -        toolkit.realSync();
   16.70 -        SwingUtilities.invokeAndWait(new Runnable() {
   16.71 -            public void run() {
   16.72 -                size = jif.getSize();
   16.73 -                frame.setSize(300, 300);
   16.74 -            }
   16.75 -        });
   16.76 -        toolkit.realSync();
   16.77 -        SwingUtilities.invokeAndWait(new Runnable() {
   16.78 -            public void run() {
   16.79 -                if (jif.getSize().equals(size)) {
   16.80 -                    throw new RuntimeException("InternalFrame hasn't changed its size");
   16.81 -                }
   16.82 -                try {
   16.83 -                    jif.setIcon(true);
   16.84 -                } catch (PropertyVetoException e) {
   16.85 -                    e.printStackTrace();
   16.86 -                }
   16.87 -                location = jif.getDesktopIcon().getLocation();
   16.88 -                frame.setSize(400, 400);
   16.89 -            }
   16.90 -        });
   16.91 -        toolkit.realSync();
   16.92 -        SwingUtilities.invokeAndWait(new Runnable() {
   16.93 -            public void run() {
   16.94 -                if (jif.getDesktopIcon().getLocation().equals(location)) {
   16.95 -                    throw new RuntimeException("JDesktopIcon hasn't moved");
   16.96 -                }
   16.97 -            }
   16.98 -        });
   16.99 +        desktop.add(this.internal);
  16.100 +    }
  16.101 +
  16.102 +    public void firstAction() throws PropertyVetoException {
  16.103 +        this.internal.setMaximum(true);
  16.104 +    }
  16.105 +
  16.106 +    public void firstTest() {
  16.107 +        this.size = this.internal.getSize();
  16.108 +        resizeFrame();
  16.109 +    }
  16.110 +
  16.111 +    public void firstValidation() {
  16.112 +        if (this.internal.getSize().equals(this.size)) {
  16.113 +            throw new Error("InternalFrame hasn't changed its size");
  16.114 +        }
  16.115 +    }
  16.116 +
  16.117 +    public void secondAction() throws PropertyVetoException {
  16.118 +        this.internal.setIcon(true);
  16.119 +    }
  16.120 +
  16.121 +    public void secondTest() {
  16.122 +        this.location = this.internal.getDesktopIcon().getLocation();
  16.123 +        resizeFrame();
  16.124 +    }
  16.125 +
  16.126 +    public void secondValidation() {
  16.127 +        if (this.internal.getDesktopIcon().getLocation().equals(this.location)) {
  16.128 +            throw new Error("JDesktopIcon hasn't moved");
  16.129 +        }
  16.130 +    }
  16.131 +
  16.132 +    private void resizeFrame() {
  16.133 +        Dimension size = this.frame.getSize();
  16.134 +        size.width += 10;
  16.135 +        size.height += 10;
  16.136 +        this.frame.setSize(size);
  16.137      }
  16.138  }
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/javax/swing/JLayer/SerializationTest/SerializationTest.java	Tue Aug 18 23:40:15 2009 -0700
    17.3 @@ -0,0 +1,53 @@
    17.4 +/*
    17.5 + * @test
    17.6 + * @summary Makes sure that JLayer is synchronizable
    17.7 + * @author Alexander Potochkin
    17.8 + * @run main SerializationTest
    17.9 + */
   17.10 +
   17.11 +import javax.swing.*;
   17.12 +import javax.swing.plaf.LayerUI;
   17.13 +import java.io.ByteArrayInputStream;
   17.14 +import java.io.ObjectOutputStream;
   17.15 +import java.io.ObjectInputStream;
   17.16 +import java.io.ByteArrayOutputStream;
   17.17 +
   17.18 +public class SerializationTest {
   17.19 +
   17.20 +    public static void main(String[] args) throws Exception {
   17.21 +        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
   17.22 +        ObjectOutputStream outputStream = new ObjectOutputStream(byteArrayOutputStream);
   17.23 +
   17.24 +        JLayer<JButton> layer = new JLayer<JButton>(new JButton("Hello"));
   17.25 +
   17.26 +        layer.setUI(new TestLayerUI<JButton>());
   17.27 +
   17.28 +        outputStream.writeObject(layer);
   17.29 +        outputStream.flush();
   17.30 +
   17.31 +        ByteArrayInputStream byteArrayInputStream =
   17.32 +                        new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
   17.33 +        ObjectInputStream inputStream = new ObjectInputStream(byteArrayInputStream);
   17.34 +
   17.35 +        JLayer newLayer = (JLayer) inputStream.readObject();
   17.36 +
   17.37 +        if (newLayer.getLayout() == null) {
   17.38 +            throw new RuntimeException("JLayer's layout is null");
   17.39 +        }
   17.40 +        if (newLayer.getGlassPane() == null) {
   17.41 +            throw new RuntimeException("JLayer's glassPane is null");
   17.42 +        }
   17.43 +        if (newLayer.getUI().getClass() != layer.getUI().getClass()) {
   17.44 +            throw new RuntimeException("Different UIs");
   17.45 +        }
   17.46 +        if (newLayer.getView().getClass() != layer.getView().getClass()) {
   17.47 +            throw new RuntimeException("Different Views");
   17.48 +        }
   17.49 +    }
   17.50 +
   17.51 +    static class TestLayerUI<V extends JComponent> extends LayerUI<V> {
   17.52 +        public String toString() {
   17.53 +            return "TestLayerUI";
   17.54 +        }
   17.55 +    }
   17.56 +}
   17.57 \ No newline at end of file
    18.1 --- a/test/javax/swing/JScrollPane/Test6526631.java	Fri Aug 14 08:51:56 2009 -0700
    18.2 +++ b/test/javax/swing/JScrollPane/Test6526631.java	Tue Aug 18 23:40:15 2009 -0700
    18.3 @@ -27,10 +27,9 @@
    18.4   * @summary Resizes right-oriented scroll pane
    18.5   * @author Sergey Malenkov
    18.6   * @library ..
    18.7 - * @build SwingTest
    18.8 - * @run main Test6526631
    18.9   */
   18.10  
   18.11 +import java.awt.ComponentOrientation;
   18.12  import java.awt.Dimension;
   18.13  import javax.swing.JFrame;
   18.14  import javax.swing.JScrollBar;
   18.15 @@ -38,15 +37,13 @@
   18.16  import javax.swing.JTextArea;
   18.17  import javax.swing.JViewport;
   18.18  
   18.19 -import static java.awt.ComponentOrientation.RIGHT_TO_LEFT;
   18.20 -
   18.21  public class Test6526631 {
   18.22  
   18.23      private static final int COLS = 90;
   18.24      private static final int ROWS = 50;
   18.25      private static final int OFFSET = 10;
   18.26  
   18.27 -    public static void main(String[] args) {
   18.28 +    public static void main(String[] args) throws Throwable {
   18.29          SwingTest.start(Test6526631.class);
   18.30      }
   18.31  
   18.32 @@ -55,7 +52,7 @@
   18.33  
   18.34      public Test6526631(JFrame frame) {
   18.35          this.pane = new JScrollPane(new JTextArea(ROWS, COLS));
   18.36 -        this.pane.setComponentOrientation(RIGHT_TO_LEFT);
   18.37 +        this.pane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
   18.38          this.frame = frame;
   18.39          this.frame.add(this.pane);
   18.40      }
   18.41 @@ -79,24 +76,24 @@
   18.42      public void validateThird() {
   18.43          JViewport viewport = this.pane.getViewport();
   18.44          JScrollBar scroller = this.pane.getHorizontalScrollBar();
   18.45 -        if (!scroller.getComponentOrientation().equals(RIGHT_TO_LEFT)) {
   18.46 -            throw new IllegalStateException("unexpected component orientation");
   18.47 +        if (!scroller.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
   18.48 +            throw new Error("unexpected component orientation");
   18.49          }
   18.50          int value = scroller.getValue();
   18.51          if (value != 0) {
   18.52 -            throw new IllegalStateException("unexpected scroll value");
   18.53 +            throw new Error("unexpected scroll value");
   18.54          }
   18.55          int extent = viewport.getExtentSize().width;
   18.56          if (extent != scroller.getVisibleAmount()) {
   18.57 -            throw new IllegalStateException("unexpected visible amount");
   18.58 +            throw new Error("unexpected visible amount");
   18.59          }
   18.60          int size = viewport.getViewSize().width;
   18.61          if (size != scroller.getMaximum()) {
   18.62 -            throw new IllegalStateException("unexpected maximum");
   18.63 +            throw new Error("unexpected maximum");
   18.64          }
   18.65          int pos = size - extent - value;
   18.66          if (pos != viewport.getViewPosition().x) {
   18.67 -            throw new IllegalStateException("unexpected position");
   18.68 +            throw new Error("unexpected position");
   18.69          }
   18.70      }
   18.71  }
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/javax/swing/JTextArea/Test6593649.java	Tue Aug 18 23:40:15 2009 -0700
    19.3 @@ -0,0 +1,89 @@
    19.4 +/*
    19.5 + * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   19.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   19.24 + * have any questions.
   19.25 + */
   19.26 +
   19.27 +/* @test
   19.28 +   @bug 6593649
   19.29 +   @summary Word wrap does not work in JTextArea: long lines are not wrapped
   19.30 +   @author Lillian Angel
   19.31 +   @run main Test6593649
   19.32 +*/
   19.33 +
   19.34 +import javax.swing.*;
   19.35 +import java.awt.*;
   19.36 +
   19.37 +public class Test6593649 extends JFrame {
   19.38 +  static JTextArea txt;
   19.39 +  static JPanel innerPanel;
   19.40 +
   19.41 +  public Test6593649(Dimension d)
   19.42 +  {
   19.43 +    super("Word Wrap Testcase");
   19.44 +
   19.45 +    setSize(d);
   19.46 +
   19.47 +    final Container contentPane = getContentPane();
   19.48 +
   19.49 +    innerPanel = new JPanel();
   19.50 +    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.LINE_AXIS));
   19.51 +
   19.52 +    txt = new JTextArea("This is a long line that should wrap, but doesn't...");
   19.53 +    txt.setLineWrap(true);
   19.54 +    txt.setWrapStyleWord(true);
   19.55 +
   19.56 +    innerPanel.add(txt);
   19.57 +
   19.58 +    contentPane.add(innerPanel, BorderLayout.SOUTH);
   19.59 +  }
   19.60 +
   19.61 +  public static void main(String[] args) throws InterruptedException
   19.62 +  {
   19.63 +    int size = 100;
   19.64 +    Dimension d;
   19.65 +    Test6593649 cp;
   19.66 +    Dimension txtSize;
   19.67 +    Dimension innerSize;
   19.68 +    Dimension cpSize;
   19.69 +
   19.70 +    while (size <= 600)
   19.71 +    {
   19.72 +      d = new Dimension(size, size);
   19.73 +      cp = new Test6593649(d);
   19.74 +      cp.setVisible(true);
   19.75 +
   19.76 +      txtSize = txt.getPreferredSize();
   19.77 +      innerSize = innerPanel.getPreferredSize();
   19.78 +      cpSize = cp.getSize();
   19.79 +
   19.80 +      if (!(txtSize.getWidth() == innerPanel.getWidth() && txtSize.getHeight() == innerPanel.getHeight() &&
   19.81 +           txtSize.getWidth() <= cpSize.getWidth() && txtSize.getHeight() <= cpSize.getHeight()))
   19.82 +      {
   19.83 +        throw new RuntimeException("Test failed: Text area size does not properly match panel and frame sizes");
   19.84 +      }
   19.85 +
   19.86 +      Thread.sleep(2000);
   19.87 +
   19.88 +      cp.hide();
   19.89 +      size += 50;
   19.90 +    }
   19.91 +  }
   19.92 +}
    20.1 --- a/test/javax/swing/SwingTest.java	Fri Aug 14 08:51:56 2009 -0700
    20.2 +++ b/test/javax/swing/SwingTest.java	Tue Aug 18 23:40:15 2009 -0700
    20.3 @@ -21,7 +21,8 @@
    20.4   * have any questions.
    20.5   */
    20.6  
    20.7 -import java.io.PrintWriter;
    20.8 +import sun.awt.SunToolkit;
    20.9 +import java.awt.Toolkit;
   20.10  import java.lang.reflect.InvocationTargetException;
   20.11  import java.lang.reflect.Method;
   20.12  import java.lang.reflect.Modifier;
   20.13 @@ -30,12 +31,18 @@
   20.14  import java.util.Set;
   20.15  import java.util.TreeSet;
   20.16  import javax.swing.JFrame;
   20.17 -
   20.18 -import static javax.swing.SwingUtilities.invokeLater;
   20.19 +import javax.swing.SwingUtilities;
   20.20  
   20.21  /**
   20.22 - * SwingTestHelper is a utility class for writing regression tests
   20.23 + * SwingTest is a utility class for writing regression tests
   20.24   * that require interacting with the UI.
   20.25 + * It uses reflection to invoke all public methods without parameters.
   20.26 + * All static methods are starting on the current thread.
   20.27 + * Other methods including constructor are starting on the EDT.
   20.28 + * Between each method invocation all pending events are processed.
   20.29 + * The methods are sorted by name and invoked in that order.
   20.30 + * Failure of the test is signaled by any method throwing an exception.
   20.31 + * If no methods throw an exception the test is assumed to have passed.
   20.32   *
   20.33   * @author Sergey A. Malenkov
   20.34   */
   20.35 @@ -44,99 +51,56 @@
   20.36      private static final int WIDTH = 640;
   20.37      private static final int HEIGHT = 480;
   20.38  
   20.39 -    public static void start(Class<?> type) {
   20.40 +    public static void start(Class<?> type) throws Throwable {
   20.41          new SwingTest(type).start();
   20.42      }
   20.43  
   20.44 -    private final PrintWriter writer = new PrintWriter(System.out, true);
   20.45 +    private final Class<?> type;
   20.46 +    private final Iterator<Method> methods;
   20.47  
   20.48 -    private Class<?> type;
   20.49      private JFrame frame;
   20.50 -    private Iterator<Method> methods;
   20.51      private Object object;
   20.52      private Method method;
   20.53      private Throwable error;
   20.54  
   20.55      private SwingTest(Class<?> type) {
   20.56 +        Set<Method> methods = new TreeSet<Method>(new Comparator<Method>() {
   20.57 +            public int compare(Method first, Method second) {
   20.58 +                return first.getName().compareTo(second.getName());
   20.59 +            }
   20.60 +        });
   20.61 +        for (Method method : type.getMethods()) {
   20.62 +            if (method.getDeclaringClass().equals(type)) {
   20.63 +                if (method.getReturnType().equals(void.class)) {
   20.64 +                    if (0 == method.getParameterTypes().length) {
   20.65 +                        methods.add(method);
   20.66 +                    }
   20.67 +                }
   20.68 +            }
   20.69 +        }
   20.70          this.type = type;
   20.71 +        this.methods = methods.iterator();
   20.72      }
   20.73  
   20.74      public void run() {
   20.75 -        synchronized (this.writer) {
   20.76 -            if (this.error != null) {
   20.77 -                this.frame.dispose();
   20.78 -                this.frame = null;
   20.79 -            }
   20.80 -            else if (this.object == null) {
   20.81 -                invoke();
   20.82 -                Set<Method> methods = new TreeSet<Method>(new Comparator<Method>() {
   20.83 -                    public int compare(Method first, Method second) {
   20.84 -                        return first.getName().compareTo(second.getName());
   20.85 -                    }
   20.86 -                });
   20.87 -                for (Method method : this.type.getMethods()) {
   20.88 -                    if (method.getDeclaringClass().equals(this.type)) {
   20.89 -                        if (method.getReturnType().equals(void.class)) {
   20.90 -                            if (0 == method.getParameterTypes().length) {
   20.91 -                                methods.add(method);
   20.92 -                            }
   20.93 -                        }
   20.94 -                    }
   20.95 -                }
   20.96 -                this.methods = methods.iterator();
   20.97 -            }
   20.98 -            else if (this.method != null) {
   20.99 -                invoke();
  20.100 -            }
  20.101 -            else if (this.methods.hasNext()) {
  20.102 -                this.method = this.methods.next();
  20.103 -            }
  20.104 -            else {
  20.105 -                this.frame.dispose();
  20.106 -                this.frame = null;
  20.107 -                this.type = null;
  20.108 -            }
  20.109 -            this.writer.notifyAll();
  20.110 -        }
  20.111 -    }
  20.112 -
  20.113 -    private void start() {
  20.114 -        synchronized (this.writer) {
  20.115 -            while (this.type != null) {
  20.116 -                if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
  20.117 -                    invoke();
  20.118 -                }
  20.119 -                else {
  20.120 -                    invokeLater(this);
  20.121 -                    try {
  20.122 -                        this.writer.wait();
  20.123 -                    }
  20.124 -                    catch (InterruptedException exception) {
  20.125 -                        exception.printStackTrace(this.writer);
  20.126 -                    }
  20.127 -                }
  20.128 -                if ((this.frame == null) && (this.error != null)) {
  20.129 -                    throw new Error("unexpected error", this.error);
  20.130 -                }
  20.131 -            }
  20.132 -        }
  20.133 -    }
  20.134 -
  20.135 -    private void invoke() {
  20.136          try {
  20.137 -            if (this.method != null) {
  20.138 -                this.writer.println(this.method);
  20.139 -                this.method.invoke(this.object);
  20.140 -                this.method = null;
  20.141 -            }
  20.142 -            else {
  20.143 -                this.writer.println(this.type);
  20.144 +            if (this.object == null) {
  20.145 +                System.out.println(this.type);
  20.146                  this.frame = new JFrame(this.type.getSimpleName());
  20.147                  this.frame.setSize(WIDTH, HEIGHT);
  20.148                  this.frame.setLocationRelativeTo(null);
  20.149 -                this.object = this.type.getConstructor(JFrame.class).newInstance(this.frame);
  20.150 +                this.object = this.type.getConstructor(this.frame.getClass()).newInstance(this.frame);
  20.151                  this.frame.setVisible(true);
  20.152              }
  20.153 +            else if (this.method != null) {
  20.154 +                System.out.println(this.method);
  20.155 +                this.method.invoke(this.object);
  20.156 +            }
  20.157 +            else {
  20.158 +                System.out.println((this.error == null) ? "PASSED" : "FAILED"); // NON-NLS: debug
  20.159 +                this.frame.dispose();
  20.160 +                this.frame = null;
  20.161 +            }
  20.162          }
  20.163          catch (NoSuchMethodException exception) {
  20.164              this.error = exception;
  20.165 @@ -156,5 +120,29 @@
  20.166          catch (InvocationTargetException exception) {
  20.167              this.error = exception.getTargetException();
  20.168          }
  20.169 +        System.out.flush();
  20.170 +        this.method = this.methods.hasNext() && (this.error == null)
  20.171 +                ? this.methods.next()
  20.172 +                : null;
  20.173 +    }
  20.174 +
  20.175 +    private void start() throws Throwable {
  20.176 +        do {
  20.177 +            if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
  20.178 +                run(); // invoke static method on the current thread
  20.179 +            }
  20.180 +            else {
  20.181 +                SwingUtilities.invokeLater(this); // invoke on the event dispatch thread
  20.182 +            }
  20.183 +            Toolkit tk = Toolkit.getDefaultToolkit();
  20.184 +            if (tk instanceof SunToolkit) {
  20.185 +                SunToolkit stk = (SunToolkit) tk;
  20.186 +                stk.realSync(); // wait until done
  20.187 +            }
  20.188 +        }
  20.189 +        while (this.frame != null);
  20.190 +        if (this.error != null) {
  20.191 +            throw this.error;
  20.192 +        }
  20.193      }
  20.194  }
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/javax/swing/text/GlyphView/6539700/bug6539700.java	Tue Aug 18 23:40:15 2009 -0700
    21.3 @@ -0,0 +1,114 @@
    21.4 +/*
    21.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   21.24 + * have any questions.
   21.25 + */
   21.26 +
   21.27 +/*
   21.28 + * @test
   21.29 + * @bug 6539700
   21.30 + * @summary test that the long space-less lines are correctly soft-wrapped
   21.31 + * @author Sergey Groznyh
   21.32 + * @run main bug6539700
   21.33 + */
   21.34 +
   21.35 +import javax.swing.JEditorPane;
   21.36 +import javax.swing.JFrame;
   21.37 +import javax.swing.SwingUtilities;
   21.38 +import javax.swing.text.ParagraphView;
   21.39 +import javax.swing.text.View;
   21.40 +
   21.41 +public class bug6539700 {
   21.42 +    static JFrame f;
   21.43 +    static JEditorPane ep;
   21.44 +    static String text = "AAAAAAAA<b>AAAAAA</b>AAAAAAAA<b>AAAAAAAAA</b>" +
   21.45 +                         "AA<b>AAA</b>AAAAAAAAA";
   21.46 +    static int size = 100;
   21.47 +    static Class rowClass = null;
   21.48 +
   21.49 +    static void createContentPane() {
   21.50 +        ep = new JEditorPane();
   21.51 +        ep.setContentType("text/html");
   21.52 +        ep.setEditable(false);
   21.53 +        ep.setText(text);
   21.54 +        f = new JFrame();
   21.55 +        f.setSize(size, 2 * size);
   21.56 +        f.add(ep);
   21.57 +        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   21.58 +        f.setVisible(true);
   21.59 +    }
   21.60 +
   21.61 +    static void checkRows(View v, boolean last) {
   21.62 +        int width = (int) v.getPreferredSpan(View.X_AXIS);
   21.63 +
   21.64 +        if (v.getClass() == rowClass) {
   21.65 +            // Row width shouldn't exceed the container width
   21.66 +            if (width > size) {
   21.67 +                throw new RuntimeException("too long row: " + width);
   21.68 +            }
   21.69 +
   21.70 +            // Row shouldn't be too short (except for the last one)
   21.71 +            if (!last) {
   21.72 +                if (width < size * 2 / 3) {
   21.73 +                    throw new RuntimeException("too short row: " + width);
   21.74 +                }
   21.75 +            }
   21.76 +        }
   21.77 +
   21.78 +        int n = v.getViewCount();
   21.79 +        if (n > 0) {
   21.80 +            for (int i = 0; i < n; i++) {
   21.81 +                View c = v.getView(i);
   21.82 +                checkRows(c, i == n - 1);
   21.83 +            }
   21.84 +        }
   21.85 +    }
   21.86 +
   21.87 +    public static void main(String[] argv) {
   21.88 +        try {
   21.89 +            SwingUtilities.invokeAndWait(new Runnable() {
   21.90 +                public void run() {
   21.91 +                    createContentPane();
   21.92 +                }
   21.93 +            });
   21.94 +        } catch (Exception ex) {
   21.95 +            throw new RuntimeException(ex);
   21.96 +        }
   21.97 +
   21.98 +        Class[] pvchildren = ParagraphView.class.getDeclaredClasses();
   21.99 +        for (Class c : pvchildren) {
  21.100 +            if (c.getName().equals("javax.swing.text.ParagraphView$Row")) {
  21.101 +                rowClass = c;
  21.102 +                break;
  21.103 +            }
  21.104 +        }
  21.105 +        if (rowClass == null) {
  21.106 +            throw new RuntimeException("can't find ParagraphView.Row class");
  21.107 +        }
  21.108 +
  21.109 +        SwingUtilities.invokeLater(new Runnable() {
  21.110 +            public void run() {
  21.111 +                checkRows(ep.getUI().getRootView(ep), true);
  21.112 +            }
  21.113 +        });
  21.114 +
  21.115 +        System.out.println("OK");
  21.116 +    }
  21.117 +}