--- a/jdk/src/share/classes/java/awt/Component.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java Tue Oct 13 15:25:58 2009 -0700
@@ -94,7 +94,17 @@
* the nonmenu-related Abstract Window Toolkit components. Class
* <code>Component</code> can also be extended directly to create a
* lightweight component. A lightweight component is a component that is
- * not associated with a native opaque window.
+ * not associated with a native window. On the contrary, a heavyweight
+ * component is associated with a native window. The {@link #isLightweight()}
+ * method may be used to distinguish between the two kinds of the components.
+ * <p>
+ * Lightweight and heavyweight components may be mixed in a single component
+ * hierarchy. However, for correct operating of such a mixed hierarchy of
+ * components, the whole hierarchy must be valid. When the hierarchy gets
+ * invalidated, like after changing the bounds of components, or
+ * adding/removing components to/from containers, the whole hierarchy must be
+ * validated afterwards by means of the {@link Container#validate()} method
+ * invoked on the top-most invalid container of the hierarchy.
* <p>
* <h3>Serialization</h3>
* It is important to note that only AWT listeners which conform
@@ -1492,9 +1502,14 @@
/**
* Shows or hides this component depending on the value of parameter
* <code>b</code>.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param b if <code>true</code>, shows this component;
* otherwise, hides this component
* @see #isVisible
+ * @see #invalidate
* @since JDK1.1
*/
public void setVisible(boolean b) {
@@ -1753,10 +1768,15 @@
/**
* Sets the font of this component.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param f the font to become this component's font;
* if this parameter is <code>null</code> then this
* component will inherit the font of its parent
* @see #getFont
+ * @see #invalidate
* @since JDK1.0
* @beaninfo
* bound: true
@@ -1830,8 +1850,13 @@
/**
* Sets the locale of this component. This is a bound property.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param l the locale to become this component's locale
* @see #getLocale
+ * @see #invalidate
* @since JDK1.1
*/
public void setLocale(Locale l) {
@@ -1951,12 +1976,17 @@
* Moves this component to a new location. The top-left corner of
* the new location is specified by the <code>x</code> and <code>y</code>
* parameters in the coordinate space of this component's parent.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param x the <i>x</i>-coordinate of the new location's
* top-left corner in the parent's coordinate space
* @param y the <i>y</i>-coordinate of the new location's
* top-left corner in the parent's coordinate space
* @see #getLocation
* @see #setBounds
+ * @see #invalidate
* @since JDK1.1
*/
public void setLocation(int x, int y) {
@@ -1979,11 +2009,16 @@
* Moves this component to a new location. The top-left corner of
* the new location is specified by point <code>p</code>. Point
* <code>p</code> is given in the parent's coordinate space.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param p the point defining the top-left corner
* of the new location, given in the coordinate space of this
* component's parent
* @see #getLocation
* @see #setBounds
+ * @see #invalidate
* @since JDK1.1
*/
public void setLocation(Point p) {
@@ -2018,10 +2053,15 @@
/**
* Resizes this component so that it has width <code>width</code>
* and height <code>height</code>.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param width the new width of this component in pixels
* @param height the new height of this component in pixels
* @see #getSize
* @see #setBounds
+ * @see #invalidate
* @since JDK1.1
*/
public void setSize(int width, int height) {
@@ -2043,10 +2083,15 @@
/**
* Resizes this component so that it has width <code>d.width</code>
* and height <code>d.height</code>.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param d the dimension specifying the new size
* of this component
* @see #setSize
* @see #setBounds
+ * @see #invalidate
* @since JDK1.1
*/
public void setSize(Dimension d) {
@@ -2089,6 +2134,10 @@
* Moves and resizes this component. The new location of the top-left
* corner is specified by <code>x</code> and <code>y</code>, and the
* new size is specified by <code>width</code> and <code>height</code>.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param x the new <i>x</i>-coordinate of this component
* @param y the new <i>y</i>-coordinate of this component
* @param width the new <code>width</code> of this component
@@ -2099,6 +2148,7 @@
* @see #setLocation(Point)
* @see #setSize(int, int)
* @see #setSize(Dimension)
+ * @see #invalidate
* @since JDK1.1
*/
public void setBounds(int x, int y, int width, int height) {
@@ -2231,12 +2281,17 @@
* position is specified by <code>r.x</code> and <code>r.y</code>,
* and its new size is specified by <code>r.width</code> and
* <code>r.height</code>
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param r the new bounding rectangle for this component
* @see #getBounds
* @see #setLocation(int, int)
* @see #setLocation(Point)
* @see #setSize(int, int)
* @see #setSize(Dimension)
+ * @see #invalidate
* @since JDK1.1
*/
public void setBounds(Rectangle r) {
@@ -6625,8 +6680,13 @@
* native screen resource.
* This method is called internally by the toolkit and should
* not be called directly by programs.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @see #isDisplayable
* @see #removeNotify
+ * @see #invalidate
* @since JDK1.0
*/
public void addNotify() {
@@ -8593,8 +8653,13 @@
* To set the orientation of an entire component
* hierarchy, use
* {@link #applyComponentOrientation applyComponentOrientation}.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
*
* @see ComponentOrientation
+ * @see #invalidate
*
* @author Laura Werner, IBM
* @beaninfo
@@ -8630,12 +8695,17 @@
/**
* Sets the <code>ComponentOrientation</code> property of this component
* and all components contained within it.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
*
* @param orientation the new component orientation of this component and
* the components contained within it.
* @exception NullPointerException if <code>orientation</code> is null.
* @see #setComponentOrientation
* @see #getComponentOrientation
+ * @see #invalidate
* @since 1.4
*/
public void applyComponentOrientation(ComponentOrientation orientation) {
--- a/jdk/src/share/classes/java/awt/Container.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Container.java Tue Oct 13 15:25:58 2009 -0700
@@ -381,16 +381,15 @@
* Appends the specified component to the end of this container.
* This is a convenience method for {@link #addImpl}.
* <p>
- * Note: If a component has been added to a container that
- * has been displayed, <code>validate</code> must be
- * called on that container to display the new component.
- * If multiple components are being added, you can improve
- * efficiency by calling <code>validate</code> only once,
- * after all the components have been added.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
*
* @param comp the component to be added
* @exception NullPointerException if {@code comp} is {@code null}
* @see #addImpl
+ * @see #invalidate
* @see #validate
* @see javax.swing.JComponent#revalidate()
* @return the component argument
@@ -406,8 +405,15 @@
* <p>
* This method is obsolete as of 1.1. Please use the
* method <code>add(Component, Object)</code> instead.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
+ *
* @exception NullPointerException if {@code comp} is {@code null}
* @see #add(Component, Object)
+ * @see #invalidate
*/
public Component add(String name, Component comp) {
addImpl(comp, name, -1);
@@ -419,12 +425,11 @@
* position.
* This is a convenience method for {@link #addImpl}.
* <p>
- * Note: If a component has been added to a container that
- * has been displayed, <code>validate</code> must be
- * called on that container to display the new component.
- * If multiple components are being added, you can improve
- * efficiency by calling <code>validate</code> only once,
- * after all the components have been added.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
+ *
*
* @param comp the component to be added
* @param index the position at which to insert the component,
@@ -435,6 +440,7 @@
* @return the component <code>comp</code>
* @see #addImpl
* @see #remove
+ * @see #invalidate
* @see #validate
* @see javax.swing.JComponent#revalidate()
*/
@@ -700,6 +706,9 @@
* This property is guaranteed to apply only to lightweight
* non-<code>Container</code> components.
* <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ * <p>
* <b>Note</b>: Not all platforms support changing the z-order of
* heavyweight components from one container into another without
* the call to <code>removeNotify</code>. There is no way to detect
@@ -723,6 +732,7 @@
* @exception IllegalArgumentException if adding a <code>Window</code>
* to a container
* @see #getComponentZOrder(java.awt.Component)
+ * @see #invalidate
* @since 1.5
*/
public void setComponentZOrder(Component comp, int index) {
@@ -923,18 +933,18 @@
* this container's layout using the specified constraints object.
* This is a convenience method for {@link #addImpl}.
* <p>
- * Note: If a component has been added to a container that
- * has been displayed, <code>validate</code> must be
- * called on that container to display the new component.
- * If multiple components are being added, you can improve
- * efficiency by calling <code>validate</code> only once,
- * after all the components have been added.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
+ *
*
* @param comp the component to be added
* @param constraints an object expressing
* layout contraints for this component
* @exception NullPointerException if {@code comp} is {@code null}
* @see #addImpl
+ * @see #invalidate
* @see #validate
* @see javax.swing.JComponent#revalidate()
* @see LayoutManager
@@ -951,12 +961,11 @@
* the specified constraints object.
* This is a convenience method for {@link #addImpl}.
* <p>
- * Note: If a component has been added to a container that
- * has been displayed, <code>validate</code> must be
- * called on that container to display the new component.
- * If multiple components are being added, you can improve
- * efficiency by calling <code>validate</code> only once,
- * after all the components have been added.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
+ *
*
* @param comp the component to be added
* @param constraints an object expressing layout contraints for this
@@ -967,6 +976,7 @@
* @exception IllegalArgumentException if {@code index} is invalid (see
* {@link #addImpl} for details)
* @see #addImpl
+ * @see #invalidate
* @see #validate
* @see javax.swing.JComponent#revalidate()
* @see #remove
@@ -1014,6 +1024,11 @@
* <code>super.addImpl(comp, constraints, index)</code>
* </blockquote>
* <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
+ *
* @param comp the component to be added
* @param constraints an object expressing layout constraints
* for this component
@@ -1033,6 +1048,7 @@
* @see #add(Component)
* @see #add(Component, int)
* @see #add(Component, java.lang.Object)
+ * @see #invalidate
* @see LayoutManager
* @see LayoutManager2
* @since JDK1.1
@@ -1145,19 +1161,18 @@
* This method also notifies the layout manager to remove the
* component from this container's layout via the
* <code>removeLayoutComponent</code> method.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * reflect the changes.
*
- * <p>
- * Note: If a component has been removed from a container that
- * had been displayed, {@link #validate} must be
- * called on that container to reflect changes.
- * If multiple components are being removed, you can improve
- * efficiency by calling {@link #validate} only once,
- * after all the components have been removed.
*
* @param index the index of the component to be removed
* @throws ArrayIndexOutOfBoundsException if {@code index} is not in
* range {@code [0, getComponentCount()-1]}
* @see #add
+ * @see #invalidate
* @see #validate
* @see #getComponentCount
* @since JDK1.1
@@ -1209,17 +1224,15 @@
* This method also notifies the layout manager to remove the
* component from this container's layout via the
* <code>removeLayoutComponent</code> method.
- *
* <p>
- * Note: If a component has been removed from a container that
- * had been displayed, {@link #validate} must be
- * called on that container to reflect changes.
- * If multiple components are being removed, you can improve
- * efficiency by calling {@link #validate} only once,
- * after all the components have been removed.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * reflect the changes.
*
* @param comp the component to be removed
* @see #add
+ * @see #invalidate
* @see #validate
* @see #remove(int)
*/
@@ -1239,8 +1252,15 @@
* This method also notifies the layout manager to remove the
* components from this container's layout via the
* <code>removeLayoutComponent</code> method.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * reflect the changes.
+ *
* @see #add
* @see #remove
+ * @see #invalidate
*/
public void removeAll() {
synchronized (getTreeLock()) {
@@ -1432,9 +1452,14 @@
/**
* Sets the layout manager for this container.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param mgr the specified layout manager
* @see #doLayout
* @see #getLayout
+ * @see #invalidate
*/
public void setLayout(LayoutManager mgr) {
layoutMgr = mgr;
@@ -1502,9 +1527,17 @@
* <p>If this {@code Container} is not valid, this method invokes
* the {@code validateTree} method and marks this {@code Container}
* as valid. Otherwise, no action is performed.
+ * <p>
+ * Note that the {@code invalidate()} method may invalidate not only the
+ * component it is called upon, but also the parents of the component.
+ * Therefore, to restore the validity of the hierarchy, the {@code
+ * validate()} method must be invoked on the top-most invalid container of
+ * the hierarchy. For performance reasons a developer may postpone the
+ * validation of the hierarchy till a bunch of layout-related operations
+ * completes, e.g. after adding all the children to the container.
*
* @see #add(java.awt.Component)
- * @see Component#invalidate
+ * @see #invalidate
* @see javax.swing.JComponent#revalidate()
* @see #validateTree
*/
@@ -1588,8 +1621,13 @@
/**
* Sets the font of this container.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param f The font to become this container's font.
* @see Component#getFont
+ * @see #invalidate
* @since JDK1.0
*/
public void setFont(Font f) {
@@ -3386,12 +3424,16 @@
/**
* Sets the <code>ComponentOrientation</code> property of this container
* and all components contained within it.
+ * <p>
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
*
* @param o the new component orientation of this container and
* the components contained within it.
* @exception NullPointerException if <code>orientation</code> is null.
* @see Component#setComponentOrientation
* @see Component#getComponentOrientation
+ * @see #invalidate
* @since 1.4
*/
public void applyComponentOrientation(ComponentOrientation o) {
@@ -4069,16 +4111,16 @@
mixingLog.fine("this = " + this);
}
- if (!isMixingNeeded()) {
- return;
- }
-
boolean isLightweight = isLightweight();
if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) {
recursiveShowHeavyweightChildren();
}
+ if (!isMixingNeeded()) {
+ return;
+ }
+
if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) {
recursiveApplyCurrentShape();
}
--- a/jdk/src/share/classes/java/awt/EventQueue.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/java/awt/EventQueue.java Tue Oct 13 15:25:58 2009 -0700
@@ -843,7 +843,8 @@
final void initDispatchThread() {
synchronized (this) {
- if (dispatchThread == null && !threadGroup.isDestroyed()) {
+ AppContext appContext = AppContext.getAppContext();
+ if (dispatchThread == null && !threadGroup.isDestroyed() && !appContext.isDisposed()) {
dispatchThread = (EventDispatchThread)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
--- a/jdk/src/share/classes/javax/swing/JFileChooser.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/JFileChooser.java Tue Oct 13 15:25:58 2009 -0700
@@ -715,7 +715,7 @@
* <ul>
* <li>JFileChooser.CANCEL_OPTION
* <li>JFileChooser.APPROVE_OPTION
- * <li>JFileCHooser.ERROR_OPTION if an error occurs or the
+ * <li>JFileChooser.ERROR_OPTION if an error occurs or the
* dialog is dismissed
* </ul>
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
@@ -724,6 +724,11 @@
*/
public int showDialog(Component parent, String approveButtonText)
throws HeadlessException {
+ if (dialog != null) {
+ // Prevent to show second instance of dialog if the previous one still exists
+ return JFileChooser.ERROR_OPTION;
+ }
+
if(approveButtonText != null) {
setApproveButtonText(approveButtonText);
setDialogType(CUSTOM_DIALOG);
--- a/jdk/src/share/classes/javax/swing/JLayer.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/JLayer.java Tue Oct 13 15:25:58 2009 -0700
@@ -56,28 +56,70 @@
* {@code JLayer} is a good solution if you only need to do custom painting
* over compound component or catch input events from its subcomponents.
* <pre>
+ * import javax.swing.*;
+ * import javax.swing.plaf.LayerUI;
+ * import java.awt.*;
+ *
+ * public class JLayerSample {
+ *
+ * private static JLayer<JComponent> createLayer() {
+ * // This custom layerUI will fill the layer with translucent green
+ * // and print out all mouseMotion events generated within its borders
+ * LayerUI<JComponent> layerUI = new LayerUI<JComponent>() {
+ *
+ * public void paint(Graphics g, JComponent c) {
+ * // paint the layer as is
+ * super.paint(g, c);
+ * // fill it with the translucent green
+ * g.setColor(new Color(0, 128, 0, 128));
+ * g.fillRect(0, 0, c.getWidth(), c.getHeight());
+ * }
+ *
+ * public void installUI(JComponent c) {
+ * super.installUI(c);
+ * // enable mouse motion events for the layer's subcomponents
+ * ((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK);
+ * }
+ *
+ * public void uninstallUI(JComponent c) {
+ * super.uninstallUI(c);
+ * // reset the layer event mask
+ * ((JLayer) c).setLayerEventMask(0);
+ * }
+ *
+ * // overridden method which catches MouseMotion events
+ * public void eventDispatched(AWTEvent e, JLayer<? extends JComponent> l) {
+ * System.out.println("AWTEvent detected: " + e);
+ * }
+ * };
* // create a component to be decorated with the layer
- * JPanel panel = new JPanel();
- * panel.add(new JButton("JButton"));
- * // This custom layerUI will fill the layer with translucent green
- * // and print out all mouseMotion events generated within its borders
- * LayerUI<JPanel> layerUI = new LayerUI<JPanel>() {
- * public void paint(Graphics g, JCompo nent c) {
- * // paint the layer as is
- * super.paint(g, c);
- * // fill it with the translucent green
- * g.setColor(new Color(0, 128, 0, 128));
- * g.fillRect(0, 0, c.getWidth(), c.getHeight());
- * }
- * // overridden method which catches MouseMotion events
- * public void eventDispatched(AWTEvent e, JLayer<JPanel> l) {
- * System.out.println("AWTEvent detected: " + e);
- * }
- * };
- * // create the layer for the panel using our custom layerUI
- * JLayer<JPanel> layer = new JLayer<JPanel>(panel, layerUI);
- * // work with the layer as with any other Swing component
- * frame.add(layer);
+ * JPanel panel = new JPanel();
+ * panel.add(new JButton("JButton"));
+ *
+ * // create the layer for the panel using our custom layerUI
+ * return new JLayer<JComponent>(panel, layerUI);
+ * }
+ *
+ * private static void createAndShowGUI() {
+ * final JFrame frame = new JFrame();
+ * frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ *
+ * // work with the layer as with any other Swing component
+ * frame.add(createLayer());
+ *
+ * frame.setSize(200, 200);
+ * frame.setLocationRelativeTo(null);
+ * frame.setVisible(true);
+ * }
+ *
+ * public static void main(String[] args) throws Exception {
+ * SwingUtilities.invokeAndWait(new Runnable() {
+ * public void run() {
+ * createAndShowGUI();
+ * }
+ * });
+ * }
+ * }
* </pre>
*
* <b>Note:</b> {@code JLayer} doesn't support the following methods:
@@ -291,7 +333,9 @@
* {@inheritDoc}
*/
public void remove(Component comp) {
- if (comp == getView()) {
+ if (comp == null) {
+ super.remove(comp);
+ } else if (comp == getView()) {
setView(null);
} else if (comp == getGlassPane()) {
setGlassPane(null);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -1766,7 +1766,7 @@
}
private boolean isTypeAheadKey( KeyEvent e ) {
- return !e.isAltDown() && !e.isControlDown() && !e.isMetaDown();
+ return !e.isAltDown() && !BasicGraphicsUtils.isMenuShortcutKeyDown(e);
}
//
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Tue Oct 13 15:25:58 2009 -0700
@@ -483,11 +483,12 @@
protected JList createList() {
return new JList( comboBox.getModel() ) {
public void processMouseEvent(MouseEvent e) {
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// Fix for 4234053. Filter out the Control Key from the list.
// ie., don't allow CTRL key deselection.
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(),
- e.getModifiers() ^ InputEvent.CTRL_MASK,
+ e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(),
e.getX(), e.getY(),
e.getXOnScreen(), e.getYOnScreen(),
e.getClickCount(),
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -924,7 +924,8 @@
boolean isTrav = (selectedFile != null && chooser.isTraversable(selectedFile));
boolean isDirSelEnabled = chooser.isDirectorySelectionEnabled();
boolean isFileSelEnabled = chooser.isFileSelectionEnabled();
- boolean isCtrl = (e != null && (e.getModifiers() & ActionEvent.CTRL_MASK) != 0);
+ boolean isCtrl = (e != null && (e.getModifiers() &
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0);
if (isDir && isTrav && (isCtrl || !isDirSelEnabled)) {
changeDirectory(selectedFile);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java Tue Oct 13 15:25:58 2009 -0700
@@ -33,7 +33,10 @@
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
+import java.awt.Toolkit;
import java.awt.event.KeyEvent;
+import java.awt.event.InputEvent;
+
import sun.swing.SwingUtilities2;
@@ -303,4 +306,9 @@
static boolean isLeftToRight( Component c ) {
return c.getComponentOrientation().isLeftToRight();
}
+
+ static boolean isMenuShortcutKeyDown(InputEvent event) {
+ return (event.getModifiers() &
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
+ }
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -2371,8 +2371,9 @@
JList src = (JList)e.getSource();
ListModel model = src.getModel();
- if (model.getSize() == 0 || e.isAltDown() || e.isControlDown() || e.isMetaDown() ||
- isNavigationKey(e)) {
+ if (model.getSize() == 0 || e.isAltDown() ||
+ BasicGraphicsUtils.isMenuShortcutKeyDown(e) ||
+ isNavigationKey(e)) {
// Nothing to select
return;
}
@@ -2665,7 +2666,7 @@
if (row != -1 && DragRecognitionSupport.mousePressed(e)) {
dragPressDidSelection = false;
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// do nothing for control - will be handled on release
// or when drag starts
return;
@@ -2717,7 +2718,7 @@
anchorSelected = list.isSelectedIndex(anchorIndex);
}
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
if (e.isShiftDown()) {
if (anchorSelected) {
list.addSelectionInterval(anchorIndex, row);
@@ -2742,7 +2743,7 @@
}
public void dragStarting(MouseEvent me) {
- if (me.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) {
int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint());
list.addSelectionInterval(row, row);
}
@@ -2758,7 +2759,7 @@
return;
}
- if (e.isShiftDown() || e.isControlDown()) {
+ if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
return;
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -196,10 +196,6 @@
return getHandler();
}
- protected MenuKeyListener createMenuKeyListener(JComponent c) {
- return (MenuKeyListener)getHandler();
- }
-
public Dimension getMaximumSize(JComponent c) {
if (((JMenu)menuItem).isTopLevelMenu() == true) {
Dimension d = c.getPreferredSize();
@@ -401,8 +397,7 @@
public void stateChanged(ChangeEvent e) { }
}
- private class Handler extends BasicMenuItemUI.Handler implements
- MenuKeyListener {
+ private class Handler extends BasicMenuItemUI.Handler {
//
// PropertyChangeListener
//
@@ -585,45 +580,5 @@
}
public void menuDragMouseExited(MenuDragMouseEvent e) {}
public void menuDragMouseReleased(MenuDragMouseEvent e) {}
-
-
- //
- // MenuKeyListener
- //
- /**
- * Open the Menu
- */
- public void menuKeyTyped(MenuKeyEvent e) {
- if (!crossMenuMnemonic && BasicPopupMenuUI.getLastPopup() != null) {
- // when crossMenuMnemonic is not set, we don't open a toplevel
- // menu if another toplevel menu is already open
- return;
- }
-
- char key = Character.toLowerCase((char)menuItem.getMnemonic());
- MenuElement path[] = e.getPath();
- MenuSelectionManager manager = e.getMenuSelectionManager();
- if (key == Character.toLowerCase(e.getKeyChar())) {
- JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu();
- ArrayList<MenuElement> newList = new ArrayList<MenuElement>(Arrays.asList(path));
- newList.add(popupMenu);
- MenuElement subs[] = popupMenu.getSubElements();
- MenuElement sub =
- BasicPopupMenuUI.findEnabledChild(subs, -1, true);
- if(sub != null) {
- newList.add(sub);
- }
- MenuElement newPath[] = new MenuElement[0];
- newPath = newList.toArray(newPath);
- manager.setSelectedPath(newPath);
- e.consume();
- } else if (((JMenu)menuItem).isTopLevelMenu()
- && BasicPopupMenuUI.getLastPopup() == null) {
- manager.clearSelectedPath();
- }
- }
-
- public void menuKeyPressed(MenuKeyEvent e) {}
- public void menuKeyReleased(MenuKeyEvent e) {}
}
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -339,7 +339,7 @@
indexes[matches++] = j;
}
}
- if (item.isArmed()) {
+ if (item.isArmed() || item.isSelected()) {
currentIndex = matches - 1;
}
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -1027,7 +1027,7 @@
shouldStartTimer =
table.isCellSelected(pressedRow, pressedCol) &&
!e.isShiftDown() &&
- !e.isControlDown() &&
+ !BasicGraphicsUtils.isMenuShortcutKeyDown(e) &&
!outsidePrefSize;
}
@@ -1051,7 +1051,7 @@
dragPressDidSelection = false;
- if (e.isControlDown() && isFileList) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e) && isFileList) {
// do nothing for control - will be handled on release
// or when drag starts
return;
@@ -1115,7 +1115,9 @@
CellEditor editor = table.getCellEditor();
if (dragEnabled || editor == null || editor.shouldSelectCell(e)) {
- table.changeSelection(pressedRow, pressedCol, e.isControlDown(), e.isShiftDown());
+ table.changeSelection(pressedRow, pressedCol,
+ BasicGraphicsUtils.isMenuShortcutKeyDown(e),
+ e.isShiftDown());
}
}
@@ -1212,7 +1214,7 @@
public void dragStarting(MouseEvent me) {
dragStarted = true;
- if (me.isControlDown() && isFileList) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(me) && isFileList) {
table.getSelectionModel().addSelectionInterval(pressedRow,
pressedRow);
table.getColumnModel().getSelectionModel().
@@ -1251,7 +1253,8 @@
return;
}
- table.changeSelection(row, column, e.isControlDown(), true);
+ table.changeSelection(row, column,
+ BasicGraphicsUtils.isMenuShortcutKeyDown(e), true);
}
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Tue Oct 13 15:25:58 2009 -0700
@@ -2265,7 +2265,7 @@
*/
protected boolean isToggleSelectionEvent(MouseEvent event) {
return (SwingUtilities.isLeftMouseButton(event) &&
- event.isControlDown());
+ BasicGraphicsUtils.isMenuShortcutKeyDown(event));
}
/**
@@ -3255,7 +3255,7 @@
// handle first letter navigation
if(tree != null && tree.getRowCount()>0 && tree.hasFocus() &&
tree.isEnabled()) {
- if (e.isAltDown() || e.isControlDown() || e.isMetaDown() ||
+ if (e.isAltDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e) ||
isNavigationKey(e)) {
return;
}
@@ -3511,7 +3511,7 @@
dragPressDidSelection = false;
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// do nothing for control - will be handled on release
// or when drag starts
return;
@@ -3565,7 +3565,7 @@
public void dragStarting(MouseEvent me) {
dragStarted = true;
- if (me.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) {
tree.addSelectionPath(pressedPath);
setAnchorSelectionPath(pressedPath);
setLeadSelectionPath(pressedPath, true);
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf Tue Oct 13 15:25:58 2009 -0700
@@ -14824,7 +14824,9 @@
<background/>
<cacheSettingsInherited>false</cacheSettingsInherited>
<cacheMode>NO_CACHING</cacheMode>
- <uiproperties/>
+ <uiproperties>
+ <uiProperty name="textIconGap" type="INT" value="5"/>
+ </uiproperties>
</style>
<backgroundStates>
<state stateKeys="Disabled">
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Tue Oct 13 15:25:58 2009 -0700
@@ -475,11 +475,11 @@
return result;
}
- static void applyInsets(Rectangle rect, Insets insets) {
+ static void applyInsets(Rectangle rect, Insets insets, boolean leftToRight) {
if (insets != null) {
- rect.x += insets.left;
+ rect.x += (leftToRight ? insets.left : insets.right);
rect.y += insets.top;
- rect.width -= (insets.right + rect.x);
+ rect.width -= (leftToRight ? insets.right : insets.left) + rect.x;
rect.height -= (insets.bottom + rect.y);
}
}
@@ -492,12 +492,12 @@
g.setFont(style.getFont(context));
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
- applyInsets(viewRect, mi.getInsets());
+ boolean leftToRight = SynthLookAndFeel.isLeftToRight(mi);
+ applyInsets(viewRect, mi.getInsets(), leftToRight);
SynthMenuItemLayoutHelper lh = new SynthMenuItemLayoutHelper(
- context, accContext, mi, checkIcon,
- arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
- SynthLookAndFeel.isLeftToRight(mi),
+ context, accContext, mi, checkIcon, arrowIcon, viewRect,
+ defaultTextIconGap, acceleratorDelimiter, leftToRight,
MenuItemLayoutHelper.useCheckAndArrow(mi), propertyPrefix);
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Tue Oct 13 15:25:58 2009 -0700
@@ -510,7 +510,7 @@
if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
getDot() != -1) {
moveCaret(e);
- } else {
+ } else if (!e.isPopupTrigger()) {
positionCaret(e);
}
}
--- a/jdk/src/share/classes/javax/swing/text/TextLayoutStrategy.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/text/TextLayoutStrategy.java Tue Oct 13 15:25:58 2009 -0700
@@ -30,6 +30,7 @@
import java.text.BreakIterator;
import java.awt.font.*;
import java.awt.geom.AffineTransform;
+import javax.swing.JComponent;
import javax.swing.event.DocumentEvent;
import sun.font.BidiUtils;
@@ -301,6 +302,13 @@
iter = BreakIterator.getLineInstance();
}
+ Object shaper = null;
+ if (c instanceof JComponent) {
+ shaper = ((JComponent) c).getClientProperty(
+ TextAttribute.NUMERIC_SHAPING);
+ }
+ text.setShaper(shaper);
+
measurer = new LineBreakMeasurer(text, iter, frc);
// If the children of the FlowView's logical view are GlyphViews, they
@@ -399,6 +407,10 @@
return pos - v.getStartOffset() + getBeginIndex();
}
+ private void setShaper(Object shaper) {
+ this.shaper = shaper;
+ }
+
// --- AttributedCharacterIterator methods -------------------------
/**
@@ -511,6 +523,8 @@
} else if( attribute == TextAttribute.RUN_DIRECTION ) {
return
v.getDocument().getProperty(TextAttribute.RUN_DIRECTION);
+ } else if (attribute == TextAttribute.NUMERIC_SHAPING) {
+ return shaper;
}
return null;
}
@@ -532,8 +546,10 @@
keys = new HashSet<Attribute>();
keys.add(TextAttribute.FONT);
keys.add(TextAttribute.RUN_DIRECTION);
+ keys.add(TextAttribute.NUMERIC_SHAPING);
}
+ private Object shaper = null;
}
}
--- a/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java Tue Oct 13 15:25:58 2009 -0700
@@ -154,14 +154,17 @@
/**
* Add a specified thread to the set of busy event dispatch threads.
- * If this set already contains the specified thread, the call leaves
- * this set unchanged and returns silently.
+ * If this set already contains the specified thread or the thread is null,
+ * the call leaves this set unchanged and returns silently.
*
* @param thread thread to be added to this set, if not present.
* @see AWTAutoShutdown#notifyThreadFree
* @see AWTAutoShutdown#isReadyToShutdown
*/
public void notifyThreadBusy(final Thread thread) {
+ if (thread == null) {
+ return;
+ }
synchronized (activationLock) {
synchronized (mainLock) {
if (blockerThread == null) {
@@ -177,14 +180,17 @@
/**
* Remove a specified thread from the set of busy event dispatch threads.
- * If this set doesn't contain the specified thread, the call leaves
- * this set unchanged and returns silently.
+ * If this set doesn't contain the specified thread or the thread is null,
+ * the call leaves this set unchanged and returns silently.
*
* @param thread thread to be removed from this set, if present.
* @see AWTAutoShutdown#notifyThreadBusy
* @see AWTAutoShutdown#isReadyToShutdown
*/
public void notifyThreadFree(final Thread thread) {
+ if (thread == null) {
+ return;
+ }
synchronized (activationLock) {
synchronized (mainLock) {
busyThreadSet.remove(thread);
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java Tue Oct 13 15:25:58 2009 -0700
@@ -57,8 +57,9 @@
* folders, such as Desktop, Documents, History, Network, Home, etc.
* This is used in the shortcut panel of the filechooser on Windows 2000
* and Windows Me.
- * "fileChooserIcon nn":
- * Returns an <code>Image</code> - icon nn from resource 124 in comctl32.dll (Windows only).
+ * "fileChooserIcon <icon>":
+ * Returns an <code>Image</code> - icon can be ListView, DetailsView, UpFolder, NewFolder or
+ * ViewMenu (Windows only).
*
* @return An Object matching the key string.
*/
--- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java Tue Oct 13 15:25:58 2009 -0700
@@ -193,6 +193,19 @@
}
/**
+ * Fill the character buffer cache. Return the buffer length.
+ */
+ private static int syncCharsBuffer(String s) {
+ int length = s.length();
+ if ((charsBuffer == null) || (charsBuffer.length < length)) {
+ charsBuffer = s.toCharArray();
+ } else {
+ s.getChars(0, length, charsBuffer, 0);
+ }
+ return length;
+ }
+
+ /**
* checks whether TextLayout is required to handle characters.
*
* @param text characters to be tested
@@ -237,15 +250,23 @@
* Returns the left side bearing of the first character of string. The
* left side bearing is calculated from the passed in
* FontMetrics. If the passed in String is less than one
- * character, this will throw a StringIndexOutOfBoundsException exception.
+ * character {@code 0} is returned.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
* @param string String to get the left side bearing for.
+ * @throws NullPointerException if {@code string} is {@code null}
+ *
+ * @return the left side bearing of the first character of string
+ * or {@code 0} if the string is empty
*/
public static int getLeftSideBearing(JComponent c, FontMetrics fm,
String string) {
- return getLeftSideBearing(c, fm, string.charAt(0));
+ int res = 0;
+ if (!string.isEmpty()) {
+ res = getLeftSideBearing(c, fm, string.charAt(0));
+ }
+ return res;
}
/**
@@ -353,7 +374,21 @@
if (string == null || string.equals("")) {
return 0;
}
- return fm.stringWidth(string);
+ boolean needsTextLayout = ((c != null) &&
+ (c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null));
+ if (needsTextLayout) {
+ synchronized(charsBufferLock) {
+ int length = syncCharsBuffer(string);
+ needsTextLayout = isComplexLayout(charsBuffer, 0, length);
+ }
+ }
+ if (needsTextLayout) {
+ TextLayout layout = createTextLayout(c, string,
+ fm.getFont(), fm.getFontRenderContext());
+ return (int) layout.getAdvance();
+ } else {
+ return fm.stringWidth(string);
+ }
}
@@ -394,21 +429,11 @@
String string, int availTextWidth) {
// c may be null here.
String clipString = "...";
- int stringLength = string.length();
availTextWidth -= SwingUtilities2.stringWidth(c, fm, clipString);
- if (availTextWidth <= 0) {
- //can not fit any characters
- return clipString;
- }
-
boolean needsTextLayout;
synchronized (charsBufferLock) {
- if (charsBuffer == null || charsBuffer.length < stringLength) {
- charsBuffer = string.toCharArray();
- } else {
- string.getChars(0, stringLength, charsBuffer, 0);
- }
+ int stringLength = syncCharsBuffer(string);
needsTextLayout =
isComplexLayout(charsBuffer, 0, stringLength);
if (!needsTextLayout) {
@@ -425,6 +450,10 @@
if (needsTextLayout) {
FontRenderContext frc = getFontRenderContext(c, fm);
AttributedString aString = new AttributedString(string);
+ if (c != null) {
+ aString.addAttribute(TextAttribute.NUMERIC_SHAPING,
+ c.getClientProperty(TextAttribute.NUMERIC_SHAPING));
+ }
LineBreakMeasurer measurer =
new LineBreakMeasurer(aString.getIterator(), frc);
int nChars = measurer.nextOffset(availTextWidth);
@@ -465,7 +494,7 @@
*/
float screenWidth = (float)
g2d.getFont().getStringBounds(text, DEFAULT_FRC).getWidth();
- TextLayout layout = new TextLayout(text, g2d.getFont(),
+ TextLayout layout = createTextLayout(c, text, g2d.getFont(),
g2d.getFontRenderContext());
layout = layout.getJustifiedLayout(screenWidth);
@@ -505,7 +534,21 @@
}
}
- g.drawString(text, x, y);
+ boolean needsTextLayout = ((c != null) &&
+ (c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null));
+ if (needsTextLayout) {
+ synchronized(charsBufferLock) {
+ int length = syncCharsBuffer(text);
+ needsTextLayout = isComplexLayout(charsBuffer, 0, length);
+ }
+ }
+ if (needsTextLayout) {
+ TextLayout layout = createTextLayout(c, text, g2.getFont(),
+ g2.getFontRenderContext());
+ layout.draw(g2, x, y);
+ } else {
+ g.drawString(text, x, y);
+ }
if (oldAAValue != null) {
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue);
@@ -547,11 +590,7 @@
boolean needsTextLayout = isPrinting;
if (!needsTextLayout) {
synchronized (charsBufferLock) {
- if (charsBuffer == null || charsBuffer.length < textLength) {
- charsBuffer = text.toCharArray();
- } else {
- text.getChars(0, textLength, charsBuffer, 0);
- }
+ syncCharsBuffer(text);
needsTextLayout =
isComplexLayout(charsBuffer, 0, textLength);
}
@@ -567,7 +606,7 @@
Graphics2D g2d = getGraphics2D(g);
if (g2d != null) {
TextLayout layout =
- new TextLayout(text, g2d.getFont(),
+ createTextLayout(c, text, g2d.getFont(),
g2d.getFontRenderContext());
if (isPrinting) {
float screenWidth = (float)g2d.getFont().
@@ -728,7 +767,7 @@
!isFontRenderContextPrintCompatible
(deviceFontRenderContext, frc)) {
TextLayout layout =
- new TextLayout(new String(data,offset,length),
+ createTextLayout(c, new String(data, offset, length),
g2d.getFont(),
deviceFontRenderContext);
float screenWidth = (float)g2d.getFont().
@@ -846,6 +885,20 @@
return retVal;
}
+ private static TextLayout createTextLayout(JComponent c, String s,
+ Font f, FontRenderContext frc) {
+ Object shaper = (c == null ?
+ null : c.getClientProperty(TextAttribute.NUMERIC_SHAPING));
+ if (shaper == null) {
+ return new TextLayout(s, f, frc);
+ } else {
+ Map<TextAttribute, Object> a = new HashMap<TextAttribute, Object>();
+ a.put(TextAttribute.FONT, f);
+ a.put(TextAttribute.NUMERIC_SHAPING, shaper);
+ return new TextLayout(s, a, frc);
+ }
+ }
+
/*
* Checks if two given FontRenderContexts are compatible for printing.
* We can't just use equals as we want to exclude from the comparison :
--- a/jdk/src/share/native/sun/awt/giflib/gifalloc.c Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/share/native/sun/awt/giflib/gifalloc.c Tue Oct 13 15:25:58 2009 -0700
@@ -88,6 +88,7 @@
Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
if (Object->Colors == (GifColorType *) NULL) {
+ free(Object);
return ((ColorMapObject *) NULL);
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Tue Oct 13 15:25:58 2009 -0700
@@ -326,13 +326,6 @@
if (log.isLoggable(PlatformLogger.FINE)) {
dumpPeers();
}
-
- awtLock();
- try {
- XlibWrapper.XSetErrorHandler(saved_error_handler);
- } finally {
- awtUnlock();
- }
}
});
}
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java Tue Oct 13 15:25:58 2009 -0700
@@ -922,7 +922,7 @@
// Dispose the HICON
private static native void disposeIcon(long hIcon);
- public static native int[] getFileChooserBitmapBits();
+ static native int[] getStandardViewButton0(int iconIndex);
// Should be called from the COM thread
private long getIShellIcon() {
@@ -933,34 +933,6 @@
return pIShellIcon;
}
-
- static int[] fileChooserBitmapBits = null;
- static Image[] fileChooserIcons = new Image[47];
-
- static Image getFileChooserIcon(int i) {
- if (fileChooserIcons[i] != null) {
- return fileChooserIcons[i];
- } else {
- if (fileChooserBitmapBits == null) {
- fileChooserBitmapBits = getFileChooserBitmapBits();
- }
- if (fileChooserBitmapBits != null) {
- int nImages = fileChooserBitmapBits.length / (16*16);
- int[] bitmapBits = new int[16 * 16];
- for (int y = 0; y < 16; y++) {
- for (int x = 0; x < 16; x++) {
- bitmapBits[y * 16 + x] = fileChooserBitmapBits[y * (nImages * 16) + (i * 16) + x];
- }
- }
- BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
- img.setRGB(0, 0, 16, 16, bitmapBits, 0, 16);
- fileChooserIcons[i] = img;
- }
- }
- return fileChooserIcons[i];
- }
-
-
private static Image makeIcon(long hIcon, boolean getLargeIcon) {
if (hIcon != 0L && hIcon != -1L) {
// Get the bits. This has the side effect of setting the imageHash value for this object.
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Tue Oct 13 15:25:58 2009 -0700
@@ -25,7 +25,8 @@
package sun.awt.shell;
-import java.awt.Toolkit;
+import java.awt.*;
+import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
@@ -33,6 +34,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
+import java.util.List;
import java.util.concurrent.*;
import sun.security.action.LoadLibraryAction;
@@ -98,6 +100,29 @@
return parent;
}
+ private static final int VIEW_LIST = 2;
+ private static final int VIEW_DETAILS = 3;
+ private static final int VIEW_PARENTFOLDER = 8;
+ private static final int VIEW_NEWFOLDER = 11;
+
+ private static final Image[] STANDARD_VIEW_BUTTONS = new Image[12];
+
+ private static Image getStandardViewButton(int iconIndex) {
+ Image result = STANDARD_VIEW_BUTTONS[iconIndex];
+
+ if (result != null) {
+ return result;
+ }
+
+ BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
+
+ img.setRGB(0, 0, 16, 16, Win32ShellFolder2.getStandardViewButton0(iconIndex), 0, 16);
+
+ STANDARD_VIEW_BUTTONS[iconIndex] = img;
+
+ return img;
+ }
+
// Special folders
private static Win32ShellFolder2 desktop;
private static Win32ShellFolder2 drives;
@@ -105,12 +130,6 @@
private static Win32ShellFolder2 network;
private static Win32ShellFolder2 personal;
- private static final boolean USE_SHELL32_ICONS = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- public Boolean run() {
- return OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0;
- }
- });
-
static Win32ShellFolder2 getDesktop() {
if (desktop == null) {
try {
@@ -206,9 +225,9 @@
* folders, such as Desktop, Documents, History, Network, Home, etc.
* This is used in the shortcut panel of the filechooser on Windows 2000
* and Windows Me.
- * "fileChooserIcon nn":
- * Returns an <code>Image</code> - icon nn from resource 216 in shell32.dll,
- * or if not found there from resource 124 in comctl32.dll (Windows only).
+ * "fileChooserIcon <icon>":
+ * Returns an <code>Image</code> - icon can be ListView, DetailsView, UpFolder, NewFolder or
+ * ViewMenu (Windows only).
* "optionPaneIcon iconName":
* Returns an <code>Image</code> - icon from the system icon list
*
@@ -303,26 +322,23 @@
}
return folders.toArray(new File[folders.size()]);
} else if (key.startsWith("fileChooserIcon ")) {
- int i = -1;
- String name = key.substring(key.indexOf(" ")+1);
- try {
- i = Integer.parseInt(name);
- } catch (NumberFormatException ex) {
- if (name.equals("ListView")) {
- i = (USE_SHELL32_ICONS) ? 21 : 2;
- } else if (name.equals("DetailsView")) {
- i = (USE_SHELL32_ICONS) ? 23 : 3;
- } else if (name.equals("UpFolder")) {
- i = (USE_SHELL32_ICONS) ? 28 : 8;
- } else if (name.equals("NewFolder")) {
- i = (USE_SHELL32_ICONS) ? 31 : 11;
- } else if (name.equals("ViewMenu")) {
- i = (USE_SHELL32_ICONS) ? 21 : 2;
- }
+ String name = key.substring(key.indexOf(" ") + 1);
+
+ int iconIndex;
+
+ if (name.equals("ListView") || name.equals("ViewMenu")) {
+ iconIndex = VIEW_LIST;
+ } else if (name.equals("DetailsView")) {
+ iconIndex = VIEW_DETAILS;
+ } else if (name.equals("UpFolder")) {
+ iconIndex = VIEW_PARENTFOLDER;
+ } else if (name.equals("NewFolder")) {
+ iconIndex = VIEW_NEWFOLDER;
+ } else {
+ return null;
}
- if (i >= 0) {
- return Win32ShellFolder2.getFileChooserIcon(i);
- }
+
+ return getStandardViewButton(iconIndex);
} else if (key.startsWith("optionPaneIcon ")) {
Win32ShellFolder2.SystemIcon iconType;
if (key == "optionPaneIcon Error") {
--- a/jdk/src/windows/native/sun/windows/ShellFolder2.cpp Wed Oct 07 14:15:01 2009 -0700
+++ b/jdk/src/windows/native/sun/windows/ShellFolder2.cpp Tue Oct 13 15:25:58 2009 -0700
@@ -256,7 +256,6 @@
static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) {
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
HRESULT hres;
- HICON hIcon = NULL;
IShellIcon* pIShellIcon;
if (pIShellFolder != NULL) {
hres = pIShellFolder->QueryInterface(IID_IShellIcon, (void**)&pIShellIcon);
@@ -965,89 +964,40 @@
/*
* Class: sun_awt_shell_Win32ShellFolder2
- * Method: getFileChooserBitmapBits
- * Signature: ()[I
+ * Method: getStandardViewButton0
+ * Signature: (I)[I
*/
-JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getFileChooserBitmapBits
- (JNIEnv* env, jclass cls)
+JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getStandardViewButton0
+ (JNIEnv* env, jclass cls, jint iconIndex)
{
- HBITMAP hBitmap = NULL;
- BITMAP bm;
- HINSTANCE libComCtl32;
- HINSTANCE libShell32;
+ jintArray result = NULL;
- libShell32 = LoadLibrary(TEXT("shell32.dll"));
- if (libShell32 != NULL) {
- hBitmap = (HBITMAP)LoadImage(libShell32,
- IS_WINVISTA ? TEXT("IDB_TB_SH_DEF_16") : MAKEINTRESOURCE(216),
- IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ // Create a toolbar
+ HWND hWndToolbar = ::CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
+ 0, 0, 0, 0, 0,
+ NULL, NULL, NULL, NULL);
+
+ if (hWndToolbar != NULL) {
+ SendMessage(hWndToolbar, TB_LOADIMAGES, (WPARAM)IDB_VIEW_SMALL_COLOR, (LPARAM)HINST_COMMCTRL);
- if (hBitmap == NULL) {
- // version of shell32.dll doesn't match OS version.
- // So we either are in a Vista Compatibility Mode
- // or shell32.dll was copied from OS of another version
- hBitmap = (HBITMAP)LoadImage(libShell32,
- IS_WINVISTA ? MAKEINTRESOURCE(216) : TEXT("IDB_TB_SH_DEF_16"),
- IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ HIMAGELIST hImageList = (HIMAGELIST) SendMessage(hWndToolbar, TB_GETIMAGELIST, 0, 0);
+
+ if (hImageList != NULL) {
+ HICON hIcon = ImageList_GetIcon(hImageList, iconIndex, ILD_TRANSPARENT);
+
+ if (hIcon != NULL) {
+ result = Java_sun_awt_shell_Win32ShellFolder2_getIconBits(env, cls, ptr_to_jlong(hIcon), 16);
+
+ DestroyIcon(hIcon);
+ }
+
+ ImageList_Destroy(hImageList);
}
- }
- if (hBitmap == NULL) {
- libComCtl32 = LoadLibrary(TEXT("comctl32.dll"));
- if (libComCtl32 != NULL) {
- hBitmap = (HBITMAP)LoadImage(libComCtl32, MAKEINTRESOURCE(124),
- IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
- }
- }
- if (hBitmap == NULL) {
- return NULL;
+
+ DestroyWindow(hWndToolbar);
}
- GetObject(hBitmap, sizeof(bm), (LPSTR)&bm);
-
- // Get the screen DC
- HDC dc = GetDC(NULL);
- if (dc == NULL) {
- return NULL;
- }
-
- // Set up BITMAPINFO
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(BITMAPINFO));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = bm.bmWidth;
- bmi.bmiHeader.biHeight = -bm.bmHeight;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- // Extract the color bitmap
- int numPixels = bm.bmWidth * bm.bmHeight;
- //long colorBits[192 * 16];
- long *colorBits = (long*)safe_Malloc(numPixels * sizeof(long));
- if (GetDIBits(dc, hBitmap, 0, bm.bmHeight, colorBits, &bmi, DIB_RGB_COLORS) == 0) {
- return NULL;
- }
-
- // Release DC
- ReleaseDC(NULL, dc);
-
- // The color of the first pixel defines the transparency, according
- // to the documentation for LR_LOADTRANSPARENT at
- // http://msdn.microsoft.com/library/psdk/winui/resource_9fhi.htm
- long transparent = colorBits[0];
- for (int i=0; i < numPixels; i++) {
- if (colorBits[i] != transparent) {
- colorBits[i] |= 0xff000000;
- }
- }
-
- // Create java array
- jintArray bits = env->NewIntArray(numPixels);
- // Copy values to java array
- env->SetIntArrayRegion(bits, 0, numPixels, colorBits);
- // Fix 4745575 GDI Resource Leak
- ::DeleteObject(hBitmap);
- ::FreeLibrary(libComCtl32);
- return bits;
+ return result;
}
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComponent/4337267/bug4337267.java Tue Oct 13 15:25:58 2009 -0700
@@ -0,0 +1,254 @@
+/*
+ * @test
+ * @bug 4337267
+ * @summary test that numeric shaping works in Swing components
+ * @author Sergey Groznyh
+ * @run main bug4337267
+ */
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.font.NumericShaper;
+import java.awt.font.TextAttribute;
+import java.awt.image.BufferedImage;
+import javax.swing.BoxLayout;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+public class bug4337267 {
+ TestJPanel p1, p2;
+ TestBufferedImage i1, i2;
+ JComponent[] printq;
+ JFrame window;
+ static boolean testFailed = false;
+ static boolean done = false;
+
+ String shaped =
+ "000 (E) 111 (A) \u0641\u0642\u0643 \u0662\u0662\u0662 (E) 333";
+ String text = "000 (E) 111 (A) \u0641\u0642\u0643 222 (E) 333";
+
+ void run() {
+ initUI();
+ testTextComponent();
+ testNonTextComponentHTML();
+ testNonTextComponentPlain();
+
+ doneTask();
+ }
+
+ void initUI() {
+ window = new JFrame("bug4337267");
+ window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ window.setSize(800, 600);
+ Component content = createContentPane();
+ window.add(content);
+ window.setVisible(true);
+ }
+
+ Runnable printComponents = new Runnable() {
+ public void run() {
+ printComponent(printq[0], i1);
+ printComponent(printq[1], i2);
+ }
+ };
+
+ Runnable compareRasters = new Runnable() {
+ public void run() {
+ assertEquals(p1.image, p2.image);
+ assertEquals(i1, i2);
+ }
+ };
+
+ void doneTask() {
+ final Object monitor = this;
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ done = true;
+ synchronized(monitor) {
+ monitor.notify();
+ }
+ }
+ });
+ }
+
+
+ void fail(String message) {
+ testFailed = true;
+ throw new RuntimeException(message);
+ }
+
+ void assertEquals(Object o1, Object o2) {
+ if ((o1 == null) && (o2 != null)) {
+ fail("Expected null, got " + o2);
+ } else if ((o1 != null) && (o2 == null)) {
+ fail("Expected " + o1 + ", got null");
+ } else if (!o1.equals(o2)) {
+ fail("Expected " + o1 + ", got " + o2);
+ }
+ }
+
+ void testTextComponent() {
+ System.out.println("testTextComponent:");
+ JTextArea area1 = new JTextArea();
+ injectComponent(p1, area1, false);
+ area1.setText(shaped);
+ JTextArea area2 = new JTextArea();
+ injectComponent(p2, area2, true);
+ area2.setText(text);
+ window.repaint();
+ printq = new JComponent[] { area1, area2 };
+ SwingUtilities.invokeLater(printComponents);
+ SwingUtilities.invokeLater(compareRasters);
+ }
+
+ void testNonTextComponentHTML() {
+ System.out.println("testNonTextComponentHTML:");
+ JLabel label1 = new JLabel();
+ injectComponent(p1, label1, false);
+ label1.setText("<html>" + shaped);
+ JLabel label2 = new JLabel();
+ injectComponent(p2, label2, true);
+ label2.setText("<html>" + text);
+ window.repaint();
+ printq = new JComponent[] { label1, label2 };
+ SwingUtilities.invokeLater(printComponents);
+ SwingUtilities.invokeLater(compareRasters);
+ }
+
+ void testNonTextComponentPlain() {
+ System.out.println("testNonTextComponentHTML:");
+ JLabel label1 = new JLabel();
+ injectComponent(p1, label1, false);
+ label1.setText(shaped);
+ JLabel label2 = new JLabel();
+ injectComponent(p2, label2, true);
+ label2.setText(text);
+ window.repaint();
+ printq = new JComponent[] { label1, label2 };
+ SwingUtilities.invokeLater(printComponents);
+ SwingUtilities.invokeLater(compareRasters);
+ }
+
+ void setShaping(JComponent c) {
+ c.putClientProperty(TextAttribute.NUMERIC_SHAPING,
+ NumericShaper.getContextualShaper(NumericShaper.ARABIC));
+ }
+
+ void injectComponent(JComponent p, JComponent c, boolean shape) {
+ if (shape) {
+ setShaping(c);
+ }
+ p.removeAll();
+ p.add(c);
+ }
+
+ void printComponent(JComponent c, TestBufferedImage i) {
+ Graphics g = i.getGraphics();
+ g.setColor(c.getBackground());
+ g.fillRect(0, 0, i.getWidth(), i.getHeight());
+ c.print(g);
+ }
+
+ Component createContentPane() {
+ Dimension size = new Dimension(500, 100);
+ i1 = new TestBufferedImage(size.width, size.height,
+ BufferedImage.TYPE_INT_ARGB);
+ i2 = new TestBufferedImage(size.width, size.height,
+ BufferedImage.TYPE_INT_ARGB);
+ p1 = new TestJPanel();
+ p1.setPreferredSize(size);
+ p2 = new TestJPanel();
+ p2.setPreferredSize(size);
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+ panel.add(p1);
+ panel.add(p2);
+
+ return panel;
+ }
+
+ static class TestBufferedImage extends BufferedImage {
+ int MAX_GLITCHES = 0;
+
+ TestBufferedImage(int width, int height, int imageType) {
+ super(width, height, imageType);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (! (other instanceof TestBufferedImage)) {
+ return false;
+ }
+ TestBufferedImage image2 = (TestBufferedImage) other;
+ int width = getWidth();
+ int height = getHeight();
+ if ((image2.getWidth() != width) || (image2.getHeight() != height)) {
+ return false;
+ }
+ int glitches = 0;
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ int rgb1 = getRGB(x, y);
+ int rgb2 = image2.getRGB(x, y);
+ if (rgb1 != rgb2) {
+ //System.out.println(x+" "+y+" "+rgb1+" "+rgb2);
+ glitches++;
+ }
+ }
+ }
+ return glitches <= MAX_GLITCHES;
+ }
+ }
+
+ static class TestJPanel extends JPanel {
+ TestBufferedImage image = createImage(new Dimension(1, 1));
+
+ TestBufferedImage createImage(Dimension d) {
+ return new TestBufferedImage(d.width, d.height,
+ BufferedImage.TYPE_INT_ARGB);
+ }
+
+ public void setPreferredSize(Dimension size) {
+ super.setPreferredSize(size);
+ image = createImage(size);
+ }
+
+ public void paint(Graphics g) {
+ Graphics g0 = image.getGraphics();
+ super.paint(g0);
+ g.drawImage(image, 0, 0, this);
+ }
+ }
+
+
+
+ public static void main(String[] args) throws Throwable {
+ final bug4337267 test = new bug4337267();
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ test.run();
+ }
+ });
+
+ synchronized(test) {
+ while (!done) {
+ try {
+ test.wait();
+ } catch (InterruptedException ex) {
+ // do nothing
+ }
+ }
+ }
+
+ if (testFailed) {
+ throw new RuntimeException("FAIL");
+ }
+
+ System.out.println("OK");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/6489130/bug6489130.java Tue Oct 13 15:25:58 2009 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6489130
+ * @summary FileChooserDemo hung by keeping pressing Enter key
+ * @author Pavel Porvatov
+ @run main bug6489130
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class bug6489130 {
+ private final JFileChooser chooser = new JFileChooser();
+
+ private static final CountDownLatch MUX = new CountDownLatch(1);
+
+ private final Timer timer = new Timer(1000, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ switch (state) {
+ case 0:
+ case 1: {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ chooser.showOpenDialog(null);
+ }
+ });
+
+ break;
+ }
+
+ case 2:
+ case 3: {
+ Window[] windows = Frame.getWindows();
+
+ if (windows.length > 0) {
+ windows[0].dispose();
+ }
+
+ break;
+ }
+
+ case 4: {
+ MUX.countDown();
+
+ break;
+ }
+ }
+
+ state++;
+ }
+ });
+
+ private int state = 0;
+
+ public static void main(String[] args) throws InterruptedException {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ new bug6489130().run();
+ }
+ });
+
+ if (!MUX.await(10, TimeUnit.SECONDS)) {
+ throw new RuntimeException("Timeout");
+ }
+ }
+
+ private void run() {
+ timer.start();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/6840086/bug6840086.java Tue Oct 13 15:25:58 2009 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6840086
+ @summary JFileChooser lacks icons on top right when running on Windows 7
+ @author Pavel Porvatov
+ @run main bug6840086
+*/
+
+import sun.awt.OSInfo;
+import sun.awt.shell.ShellFolder;
+
+import java.awt.*;
+
+public class bug6840086 {
+ private static final String[] KEYS = {
+ "fileChooserIcon ListView",
+ "fileChooserIcon ViewMenu",
+ "fileChooserIcon DetailsView",
+ "fileChooserIcon UpFolder",
+ "fileChooserIcon NewFolder",
+ };
+
+ public static void main(String[] args) {
+ if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+ System.out.println("The test was skipped because it is sensible only for Windows.");
+
+ return;
+ }
+
+ for (String key : KEYS) {
+ Image image = (Image) ShellFolder.get(key);
+
+ if (image == null) {
+ throw new RuntimeException("The image '" + key + "' not found.");
+ }
+
+ if (image != ShellFolder.get(key)) {
+ throw new RuntimeException("The image '" + key + "' is not cached.");
+ }
+ }
+
+ System.out.println("The test passed.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JLayer/6875716/bug6875716.java Tue Oct 13 15:25:58 2009 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6875716
+ * @summary JLayer.remove((Component)null) should behave consistently in (not) throwing NPE
+ * @author Alexander Potochkin
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+public class bug6875716 {
+
+ public static void main(String[] args) throws Exception {
+ JLayer<Component> layer = new JLayer<Component>(new Component(){});
+ layer.setGlassPane(null);
+ try {
+ layer.remove((Component)null);
+ } catch (NullPointerException e) {
+ //this is what we expect
+ return;
+ }
+ throw new RuntimeException("Test failed");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JMenuItem/6883341/bug6883341.java Tue Oct 13 15:25:58 2009 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+ /*
+ * @test
+ * @bug 6883341
+ * @summary Checks that menu items with no text don't throw an exception
+ * @author Alexander Potochkin
+ * @run main bug6883341
+ */
+
+import javax.swing.*;
+
+public class bug6883341 {
+
+ private static void createGui() {
+ JPopupMenu menu = new JPopupMenu();
+ menu.add(new JMenuItem());
+ menu.setVisible(true);
+ menu.setVisible(false);
+ }
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ bug6883341.createGui();
+ }
+ });
+ }
+}