changeset 4403:190b11164876

Merge
author lana
date Wed, 27 Jul 2011 22:42:19 -0700
parents 40d0dea5d0fc c05b36e4749e
children 996547848b00
files
diffstat 50 files changed, 1117 insertions(+), 449 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java	Wed Jul 27 22:42:19 2011 -0700
@@ -49,11 +49,11 @@
 
     private FilterComboBoxModel filterComboBoxModel;
 
-    protected JList directoryList = null;
-    protected JList fileList = null;
+    protected JList<File> directoryList = null;
+    protected JList<File> fileList = null;
 
     protected JTextField pathField = null;
-    protected JComboBox filterComboBox = null;
+    protected JComboBox<FileFilter> filterComboBox = null;
     protected JTextField filenameTextField = null;
 
     private static final Dimension hstrut10 = new Dimension(10, 1);
@@ -337,7 +337,7 @@
         align(l);
         leftPanel.add(l);
 
-        filterComboBox = new JComboBox() {
+        filterComboBox = new JComboBox<FileFilter>() {
             public Dimension getMaximumSize() {
                 Dimension d = super.getMaximumSize();
                 d.height = getPreferredSize().height;
@@ -557,7 +557,7 @@
     }
 
     protected JScrollPane createFilesList() {
-        fileList = new JList();
+        fileList = new JList<File>();
 
         if(getFileChooser().isMultiSelectionEnabled()) {
             fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
@@ -576,7 +576,7 @@
                 if (SwingUtilities.isLeftMouseButton(e) && !chooser.isMultiSelectionEnabled()) {
                     int index = SwingUtilities2.loc2IndexFileList(fileList, e.getPoint());
                     if (index >= 0) {
-                        File file = (File) fileList.getModel().getElementAt(index);
+                        File file = fileList.getModel().getElementAt(index);
                         setFileName(chooser.getName(file));
                     }
                 }
@@ -593,7 +593,7 @@
     }
 
     protected JScrollPane createDirectoryList() {
-        directoryList = new JList();
+        directoryList = new JList<File>();
         align(directoryList);
 
         directoryList.setCellRenderer(new DirectoryCellRenderer());
@@ -658,7 +658,7 @@
         }
     }
 
-    protected class MotifDirectoryListModel extends AbstractListModel implements ListDataListener {
+    protected class MotifDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
         public MotifDirectoryListModel() {
             getModel().addListDataListener(this);
         }
@@ -667,7 +667,7 @@
             return getModel().getDirectories().size();
         }
 
-        public Object getElementAt(int index) {
+        public File getElementAt(int index) {
             return getModel().getDirectories().elementAt(index);
         }
 
@@ -694,7 +694,7 @@
 
     }
 
-    protected class MotifFileListModel extends AbstractListModel implements ListDataListener {
+    protected class MotifFileListModel extends AbstractListModel<File> implements ListDataListener {
         public MotifFileListModel() {
             getModel().addListDataListener(this);
         }
@@ -711,7 +711,7 @@
             return getModel().getFiles().indexOf(o);
         }
 
-        public Object getElementAt(int index) {
+        public File getElementAt(int index) {
             return getModel().getFiles().elementAt(index);
         }
 
@@ -773,7 +773,8 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener {
+    protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+            PropertyChangeListener {
         protected FileFilter[] filters;
         protected FilterComboBoxModel() {
             super();
@@ -826,7 +827,7 @@
             }
         }
 
-        public Object getElementAt(int index) {
+        public FileFilter getElementAt(int index) {
             if(index > getSize() - 1) {
                 // This shouldn't happen. Try to recover gracefully.
                 return getFileChooser().getFileFilter();
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java	Wed Jul 27 22:42:19 2011 -0700
@@ -60,7 +60,7 @@
     private JPanel centerPanel;
 
     private JLabel lookInLabel;
-    private JComboBox directoryComboBox;
+    private JComboBox<File> directoryComboBox;
     private DirectoryComboBoxModel directoryComboBoxModel;
     private ActionListener directoryComboBoxAction = new DirectoryComboBoxAction();
 
@@ -76,7 +76,7 @@
     private JPanel buttonPanel;
     private JPanel bottomPanel;
 
-    private JComboBox filterComboBox;
+    private JComboBox<FileFilter> filterComboBox;
 
     private static final Dimension hstrut10 = new Dimension(10, 1);
 
@@ -245,7 +245,7 @@
         topPanel.add(Box.createRigidArea(new Dimension(8,0)));
 
         // CurrentDir ComboBox
-        directoryComboBox = new JComboBox() {
+        directoryComboBox = new JComboBox<File>() {
             public Dimension getMinimumSize() {
                 Dimension d = super.getMinimumSize();
                 d.width = 60;
@@ -445,7 +445,7 @@
 
         filterComboBoxModel = createFilterComboBoxModel();
         fc.addPropertyChangeListener(filterComboBoxModel);
-        filterComboBox = new JComboBox(filterComboBoxModel);
+        filterComboBox = new JComboBox<FileFilter>(filterComboBoxModel);
         ftl.setLabelFor(filterComboBox);
         filterComboBox.setRenderer(createFilterComboBoxRenderer());
         fileAndFilterPanel.add(filterComboBox);
@@ -1032,7 +1032,7 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
+    protected class DirectoryComboBoxModel extends AbstractListModel<File> implements ComboBoxModel<File> {
         Vector<File> directories = new Vector<File>();
         int[] depths = null;
         File selectedDirectory = null;
@@ -1149,7 +1149,7 @@
             return directories.size();
         }
 
-        public Object getElementAt(int index) {
+        public File getElementAt(int index) {
             return directories.elementAt(index);
         }
     }
@@ -1189,7 +1189,8 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener {
+    protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+            PropertyChangeListener {
         protected FileFilter[] filters;
         protected FilterComboBoxModel() {
             super();
@@ -1242,7 +1243,7 @@
             }
         }
 
-        public Object getElementAt(int index) {
+        public FileFilter getElementAt(int index) {
             if(index > getSize() - 1) {
                 // This shouldn't happen. Try to recover gracefully.
                 return getFileChooser().getFileFilter();
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java	Wed Jul 27 22:42:19 2011 -0700
@@ -81,19 +81,22 @@
             else {
                 Rectangle   beginRect = getPathBounds(tree, getPathForRow
                                                       (tree, beginRow));
-                Rectangle   testRect = beginRect;
-                int         beginY = beginRect.y;
-                int         maxY = beginY + visRect.height;
+                if (beginRect != null) {
+                    Rectangle   testRect = beginRect;
+                    int         beginY = beginRect.y;
+                    int         maxY = beginY + visRect.height;
 
-                for(int counter = beginRow + 1; counter <= endRow; counter++) {
-                    testRect = getPathBounds(tree,
-                                             getPathForRow(tree, counter));
-                    if((testRect.y + testRect.height) > maxY)
-                        counter = endRow;
+                    for(int counter = beginRow + 1; counter <= endRow; counter++) {
+                        testRect = getPathBounds(tree,
+                                                 getPathForRow(tree, counter));
+                        if(testRect != null && (testRect.y + testRect.height) > maxY) {
+                            counter = endRow;
+                        }
+                    }
+                    tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
+                                                      testRect.y + testRect.height-
+                                                      beginY));
                 }
-                tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
-                                                  testRect.y + testRect.height-
-                                                  beginY));
             }
         }
     }
--- a/src/share/classes/java/awt/ScrollPaneAdjustable.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/java/awt/ScrollPaneAdjustable.java	Wed Jul 27 22:42:19 2011 -0700
@@ -24,6 +24,8 @@
  */
 package java.awt;
 
+import sun.awt.AWTAccessor;
+
 import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
 import java.awt.peer.ScrollPanePeer;
@@ -156,6 +158,12 @@
         if (!GraphicsEnvironment.isHeadless()) {
             initIDs();
         }
+        AWTAccessor.setScrollPaneAdjustableAccessor(new AWTAccessor.ScrollPaneAdjustableAccessor() {
+            public void setTypedValue(final ScrollPaneAdjustable adj,
+                                      final int v, final int type) {
+                adj.setTypedValue(v, type);
+            }
+        });
     }
 
     /**
--- a/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java	Wed Jul 27 22:42:19 2011 -0700
@@ -63,8 +63,7 @@
 public class BasicComboPopup extends JPopupMenu implements ComboPopup {
     // An empty ListMode, this is used when the UI changes to allow
     // the JList to be gc'ed.
-    private static class EmptyListModelClass implements ListModel,
-                                                        Serializable {
+    private static class EmptyListModelClass implements ListModel<Object>, Serializable {
         public int getSize() { return 0; }
         public Object getElementAt(int index) { return null; }
         public void addListDataListener(ListDataListener l) {}
--- a/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java	Wed Jul 27 22:42:19 2011 -0700
@@ -810,10 +810,7 @@
             putValue(Action.ACTION_COMMAND_KEY, FilePane.ACTION_CHANGE_TO_PARENT_DIRECTORY);
         }
         public void actionPerformed(ActionEvent e) {
-            Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
-            if (focusOwner == null || !(focusOwner instanceof javax.swing.text.JTextComponent)) {
-                getFileChooser().changeToParentDirectory();
-            }
+            getFileChooser().changeToParentDirectory();
         }
     }
 
--- a/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Wed Jul 27 22:42:19 2011 -0700
@@ -444,7 +444,7 @@
      * renderer installed on a Synth combo box is a JLabel. If this is changed,
      * then an assert will fail in SynthFileChooserUIImpl
      */
-    private class SynthComboBoxRenderer extends JLabel implements ListCellRenderer, UIResource {
+    private class SynthComboBoxRenderer extends JLabel implements ListCellRenderer<Object>, UIResource {
         public SynthComboBoxRenderer() {
             super();
             setName("ComboBox.renderer");
@@ -452,7 +452,7 @@
         }
 
         @Override
-        public Component getListCellRendererComponent(JList list, Object value,
+        public Component getListCellRendererComponent(JList<?> list, Object value,
                          int index, boolean isSelected, boolean cellHasFocus) {
             setName("ComboBox.listRenderer");
             SynthLookAndFeel.resetSelectedUI();
--- a/src/share/classes/javax/swing/text/html/FormView.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/text/html/FormView.java	Wed Jul 27 22:42:19 2011 -0700
@@ -725,11 +725,11 @@
         }
         Object m = attr.getAttribute(StyleConstants.ModelAttribute);
         if (m instanceof OptionListModel) {
-            OptionListModel model = (OptionListModel)m;
+            OptionListModel<Option> model = (OptionListModel<Option>) m;
 
             for (int i = 0; i < model.getSize(); i++) {
                 if (model.isSelectedIndex(i)) {
-                    Option option = (Option) model.getElementAt(i);
+                    Option option = model.getElementAt(i);
                     appendBuffer(buffer, name, option.getValue());
                 }
             }
--- a/src/share/classes/javax/swing/text/html/HTMLDocument.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/text/html/HTMLDocument.java	Wed Jul 27 22:42:19 2011 -0700
@@ -3358,13 +3358,13 @@
                                                              1);
                     boolean multiple = attr.getAttribute(HTML.Attribute.MULTIPLE) != null;
                     if ((size > 1) || multiple) {
-                        OptionListModel m = new OptionListModel();
+                        OptionListModel<Option> m = new OptionListModel<Option>();
                         if (multiple) {
                             m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                         }
                         selectModel = m;
                     } else {
-                        selectModel = new OptionComboBoxModel();
+                        selectModel = new OptionComboBoxModel<Option>();
                     }
                     attr.addAttribute(StyleConstants.ModelAttribute,
                                       selectModel);
@@ -3376,14 +3376,14 @@
                     option = new Option(attr);
 
                     if (selectModel instanceof OptionListModel) {
-                        OptionListModel m = (OptionListModel)selectModel;
+                        OptionListModel<Option> m = (OptionListModel<Option>) selectModel;
                         m.addElement(option);
                         if (option.isSelected()) {
                             m.addSelectionInterval(optionCount, optionCount);
                             m.setInitialSelection(optionCount);
                         }
                     } else if (selectModel instanceof OptionComboBoxModel) {
-                        OptionComboBoxModel m = (OptionComboBoxModel)selectModel;
+                        OptionComboBoxModel<Option> m = (OptionComboBoxModel<Option>) selectModel;
                         m.addElement(option);
                         if (option.isSelected()) {
                             m.setSelectedItem(option);
--- a/src/share/classes/javax/swing/text/html/HTMLWriter.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/text/html/HTMLWriter.java	Wed Jul 27 22:42:19 2011 -0700
@@ -527,17 +527,17 @@
         Object model = attr.getAttribute(StyleConstants.ModelAttribute);
         incrIndent();
         if (model instanceof OptionListModel) {
-            OptionListModel listModel = (OptionListModel)model;
+            OptionListModel<Option> listModel = (OptionListModel<Option>) model;
             int size = listModel.getSize();
             for (int i = 0; i < size; i++) {
-                Option option = (Option)listModel.getElementAt(i);
+                Option option = listModel.getElementAt(i);
                 writeOption(option);
             }
         } else if (model instanceof OptionComboBoxModel) {
-            OptionComboBoxModel comboBoxModel = (OptionComboBoxModel)model;
+            OptionComboBoxModel<Option> comboBoxModel = (OptionComboBoxModel<Option>) model;
             int size = comboBoxModel.getSize();
             for (int i = 0; i < size; i++) {
-                Option option = (Option)comboBoxModel.getElementAt(i);
+                Option option = comboBoxModel.getElementAt(i);
                 writeOption(option);
             }
         }
--- a/src/share/classes/javax/swing/text/html/OptionComboBoxModel.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/text/html/OptionComboBoxModel.java	Wed Jul 27 22:42:19 2011 -0700
@@ -25,7 +25,6 @@
 package javax.swing.text.html;
 
 import javax.swing.*;
-import javax.swing.event.*;
 import java.io.Serializable;
 
 
@@ -41,7 +40,7 @@
   @author Sunita Mani
  */
 
-class OptionComboBoxModel extends DefaultComboBoxModel implements Serializable {
+class OptionComboBoxModel<E> extends DefaultComboBoxModel<E> implements Serializable {
 
     private Option selectedOption = null;
 
--- a/src/share/classes/javax/swing/text/html/OptionListModel.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/javax/swing/text/html/OptionListModel.java	Wed Jul 27 22:42:19 2011 -0700
@@ -26,7 +26,6 @@
 
 import javax.swing.*;
 import javax.swing.event.*;
-import java.util.EventListener;
 import java.util.BitSet;
 import java.io.Serializable;
 
@@ -44,7 +43,7 @@
   @author Sunita Mani
  */
 
-class OptionListModel extends DefaultListModel implements ListSelectionModel, Serializable {
+class OptionListModel<E> extends DefaultListModel<E> implements ListSelectionModel, Serializable {
 
 
     private static final int MIN = -1;
--- a/src/share/classes/sun/awt/AWTAccessor.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/sun/awt/AWTAccessor.java	Wed Jul 27 22:42:19 2011 -0700
@@ -25,15 +25,12 @@
 
 package sun.awt;
 
+import sun.misc.Unsafe;
+
 import java.awt.*;
 import java.awt.event.InputEvent;
 import java.awt.geom.Point2D;
-import java.awt.image.BufferedImage;
-
-import sun.misc.Unsafe;
 import java.awt.peer.ComponentPeer;
-
-import java.security.AccessController;
 import java.security.AccessControlContext;
 
 /**
@@ -471,6 +468,17 @@
     }
 
     /*
+     * An accessor for the ScrollPaneAdjustable class.
+     */
+    public interface ScrollPaneAdjustableAccessor {
+        /*
+         * Sets the value of this scrollbar to the specified value.
+         */
+        void setTypedValue(final ScrollPaneAdjustable adj, final int v,
+                           final int type);
+    }
+
+    /*
      * Accessor instances are initialized in the static initializers of
      * corresponding AWT classes by using setters defined below.
      */
@@ -485,6 +493,7 @@
     private static EventQueueAccessor eventQueueAccessor;
     private static PopupMenuAccessor popupMenuAccessor;
     private static FileDialogAccessor fileDialogAccessor;
+    private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
 
     /*
      * Set an accessor object for the java.awt.Component class.
@@ -675,4 +684,21 @@
         return fileDialogAccessor;
     }
 
+    /*
+     * Set an accessor object for the java.awt.ScrollPaneAdjustable class.
+     */
+    public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) {
+        scrollPaneAdjustableAccessor = adj;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable
+     * class.
+     */
+    public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() {
+        if (scrollPaneAdjustableAccessor == null) {
+            unsafe.ensureClassInitialized(ScrollPaneAdjustable.class);
+        }
+        return scrollPaneAdjustableAccessor;
+    }
 }
--- a/src/share/classes/sun/swing/FilePane.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/sun/swing/FilePane.java	Wed Jul 27 22:42:19 2011 -0700
@@ -570,7 +570,7 @@
     public JPanel createList() {
         JPanel p = new JPanel(new BorderLayout());
         final JFileChooser fileChooser = getFileChooser();
-        final JList list = new JList() {
+        final JList<Object> list = new JList<Object>() {
             public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
                 ListModel model = getModel();
                 int max = model.getSize();
@@ -641,7 +641,7 @@
     /**
      * This model allows for sorting JList
      */
-    private class SortableListModel extends AbstractListModel
+    private class SortableListModel extends AbstractListModel<Object>
             implements TableModelListener, RowSorterListener {
 
         public SortableListModel() {
--- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Wed Jul 27 22:42:19 2011 -0700
@@ -60,7 +60,7 @@
  */
 public class SynthFileChooserUIImpl extends SynthFileChooserUI {
     private JLabel lookInLabel;
-    private JComboBox directoryComboBox;
+    private JComboBox<File> directoryComboBox;
     private DirectoryComboBoxModel directoryComboBoxModel;
     private Action directoryComboBoxAction = new DirectoryComboBoxAction();
 
@@ -77,10 +77,9 @@
     private JPanel buttonPanel;
     private JPanel bottomPanel;
 
-    private JComboBox filterComboBox;
+    private JComboBox<FileFilter> filterComboBox;
 
     private static final Dimension hstrut5 = new Dimension(5, 1);
-    private static final Dimension vstrut5  = new Dimension(1, 5);
 
     private static final Insets shrinkwrap = new Insets(0,0,0,0);
 
@@ -217,7 +216,7 @@
         topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);
 
         // CurrentDir ComboBox
-        directoryComboBox = new JComboBox();
+        directoryComboBox = new JComboBox<File>();
         directoryComboBox.getAccessibleContext().setAccessibleDescription(lookInLabelText);
         directoryComboBox.putClientProperty( "JComboBox.isTableCellEditor", Boolean.TRUE );
         lookInLabel.setLabelFor(directoryComboBox);
@@ -394,7 +393,7 @@
 
         filterComboBoxModel = createFilterComboBoxModel();
         fc.addPropertyChangeListener(filterComboBoxModel);
-        filterComboBox = new JComboBox(filterComboBoxModel);
+        filterComboBox = new JComboBox<FileFilter>(filterComboBoxModel);
         filterComboBox.getAccessibleContext().setAccessibleDescription(filesOfTypeLabelText);
         filesOfTypeLabel.setLabelFor(filterComboBox);
         filterComboBox.setRenderer(createFilterComboBoxRenderer());
@@ -671,16 +670,16 @@
     // looking combo boxes.
     // So what we do here is delegate most jobs to the "real" or original renderer,
     // and simply monkey with the icon and text of the renderer.
-    private class DirectoryComboBoxRenderer implements ListCellRenderer {
-        private ListCellRenderer delegate;
+    private class DirectoryComboBoxRenderer implements ListCellRenderer<File> {
+        private ListCellRenderer<? super File> delegate;
         IndentIcon ii = new IndentIcon();
 
-        private DirectoryComboBoxRenderer(ListCellRenderer delegate) {
+        private DirectoryComboBoxRenderer(ListCellRenderer<? super File> delegate) {
             this.delegate = delegate;
         }
 
         @Override
-        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+        public Component getListCellRendererComponent(JList<? extends File> list, File value, int index, boolean isSelected, boolean cellHasFocus) {
             Component c = delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 
             assert c instanceof JLabel;
@@ -689,9 +688,8 @@
                 label.setText("");
                 return label;
             }
-            File directory = (File) value;
-            label.setText(getFileChooser().getName(directory));
-            Icon icon = getFileChooser().getIcon(directory);
+            label.setText(getFileChooser().getName(value));
+            Icon icon = getFileChooser().getIcon(value);
             ii.icon = icon;
             ii.depth = directoryComboBoxModel.getDepth(index);
             label.setIcon(ii);
@@ -736,7 +734,7 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
+    protected class DirectoryComboBoxModel extends AbstractListModel<File> implements ComboBoxModel<File> {
         Vector<File> directories = new Vector<File>();
         int[] depths = null;
         File selectedDirectory = null;
@@ -857,7 +855,7 @@
             return directories.size();
         }
 
-        public Object getElementAt(int index) {
+        public File getElementAt(int index) {
             return directories.elementAt(index);
         }
     }
@@ -890,18 +888,19 @@
     /**
      * Render different type sizes and styles.
      */
-    public class FilterComboBoxRenderer implements ListCellRenderer {
-        private ListCellRenderer delegate;
-        private FilterComboBoxRenderer(ListCellRenderer delegate) {
+    public class FilterComboBoxRenderer implements ListCellRenderer<FileFilter> {
+        private ListCellRenderer<? super FileFilter> delegate;
+        private FilterComboBoxRenderer(ListCellRenderer<? super FileFilter> delegate) {
             this.delegate = delegate;
         }
 
-        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+        public Component getListCellRendererComponent(JList<? extends FileFilter> list, FileFilter value, int index,
+                                                      boolean isSelected, boolean cellHasFocus) {
             Component c = delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 
             String text = null;
-            if (value != null && value instanceof FileFilter) {
-                text = ((FileFilter) value).getDescription();
+            if (value != null) {
+                text = value.getDescription();
             }
 
             //this should always be true, since SynthComboBoxUI's SynthComboBoxRenderer
@@ -924,7 +923,8 @@
     /**
      * Data model for a type-face selection combo-box.
      */
-    protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener {
+    protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
+            PropertyChangeListener {
         protected FileFilter[] filters;
         protected FilterComboBoxModel() {
             super();
@@ -977,7 +977,7 @@
             }
         }
 
-        public Object getElementAt(int index) {
+        public FileFilter getElementAt(int index) {
             if(index > getSize() - 1) {
                 // This shouldn't happen. Try to recover gracefully.
                 return getFileChooser().getFileFilter();
--- a/src/share/classes/sun/swing/text/TextComponentPrintable.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/sun/swing/text/TextComponentPrintable.java	Wed Jul 27 22:42:19 2011 -0700
@@ -47,15 +47,7 @@
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.atomic.AtomicReference;
 
-import javax.swing.BorderFactory;
-import javax.swing.CellRendererPane;
-import javax.swing.JTextField;
-import javax.swing.JTextArea;
-import javax.swing.JEditorPane;
-import javax.swing.JViewport;
-import javax.swing.JScrollPane;
-import javax.swing.JTextPane;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
 import javax.swing.border.Border;
 import javax.swing.border.TitledBorder;
 import javax.swing.text.BadLocationException;
@@ -336,7 +328,22 @@
         assert SwingUtilities.isEventDispatchThread();
 
         JTextComponent ret = null;
-        if (textComponent instanceof JTextField) {
+        if (textComponent instanceof JPasswordField) {
+            ret =
+                new JPasswordField() {
+                    {
+                        setEchoChar(((JPasswordField) textComponent).getEchoChar());
+                        setHorizontalAlignment(
+                            ((JTextField) textComponent).getHorizontalAlignment());
+                    }
+                    @Override
+                    public FontMetrics getFontMetrics(Font font) {
+                        return (frc.get() == null)
+                            ? super.getFontMetrics(font)
+                            : FontDesignMetrics.getMetrics(font, frc.get());
+                    }
+                };
+        } else if (textComponent instanceof JTextField) {
             ret =
                 new JTextField() {
                     {
--- a/src/share/classes/sun/text/bidi/BidiBase.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/share/classes/sun/text/bidi/BidiBase.java	Wed Jul 27 22:42:19 2011 -0700
@@ -2690,6 +2690,7 @@
     public void setPara(AttributedCharacterIterator paragraph)
     {
         byte paraLvl;
+        char ch = paragraph.first();
         Boolean runDirection =
             (Boolean) paragraph.getAttribute(TextAttributeConstants.RUN_DIRECTION);
         Object shaper = paragraph.getAttribute(TextAttributeConstants.NUMERIC_SHAPING);
@@ -2705,7 +2706,6 @@
         byte[] embeddingLevels = new byte[len];
         char[] txt = new char[len];
         int i = 0;
-        char ch = paragraph.first();
         while (ch != AttributedCharacterIterator.DONE) {
             txt[i] = ch;
             Integer embedding =
@@ -3411,18 +3411,21 @@
      * Display the bidi internal state, used in debugging.
      */
     public String toString() {
-        StringBuffer buf = new StringBuffer(super.toString());
+        StringBuilder buf = new StringBuilder(getClass().getName());
 
-        buf.append("[dir: " + direction);
-        buf.append(" baselevel: " + paraLevel);
-        buf.append(" length: " + length);
+        buf.append("[dir: ");
+        buf.append(direction);
+        buf.append(" baselevel: ");
+        buf.append(paraLevel);
+        buf.append(" length: ");
+        buf.append(length);
         buf.append(" runs: ");
         if (levels == null) {
-            buf.append("null");
+            buf.append("none");
         } else {
             buf.append('[');
             buf.append(levels[0]);
-            for (int i = 0; i < levels.length; i++) {
+            for (int i = 1; i < levels.length; i++) {
                 buf.append(' ');
                 buf.append(levels[i]);
             }
@@ -3430,12 +3433,11 @@
         }
         buf.append(" text: [0x");
         buf.append(Integer.toHexString(text[0]));
-        for (int i = 0; i < text.length; i++) {
+        for (int i = 1; i < text.length; i++) {
             buf.append(" 0x");
             buf.append(Integer.toHexString(text[i]));
         }
-        buf.append(']');
-        buf.append(']');
+        buf.append("]]");
 
         return buf.toString();
     }
--- a/src/solaris/classes/sun/awt/X11/XButtonPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XButtonPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -33,12 +33,9 @@
 import javax.swing.plaf.basic.*;
 import javax.swing.SwingUtilities;
 import javax.swing.SwingConstants;
-
 public class XButtonPeer extends XComponentPeer implements ButtonPeer {
-
-    boolean pressed;
-    boolean armed;
-
+    private boolean pressed;
+    private boolean armed;
     private Insets focusInsets;
     private Insets borderInsets;
     private Insets contentAreaInsets;
@@ -86,11 +83,6 @@
         this.label = label;
         repaint();
     }
-
-    public void paint(Graphics g) {
-        paint(g,target);
-    }
-
     public void setBackground(Color c) {
         updateMotifColors(c);
         super.setBackground(c);
@@ -133,16 +125,10 @@
           case  MouseEvent.MOUSE_ENTERED:
               if (pressed)
                   armed = true;
-//                 repaint();
-
               break;
-
           case MouseEvent.MOUSE_EXITED:
               armed = false;
-//                 repaint();
-
               break;
-
         }
     }
 
@@ -209,18 +195,14 @@
     public Dimension minimumSize() {
         return getMinimumSize();
     }
-
-
-    /*
-       This method is called from Toolkit Thread and so it should not call any client code
-
-    */
-    public void paint(Graphics g, Component c)
-    {
-        if (!disposed && (g != null))
-        {
+    /**
+     * This method is called from Toolkit Thread and so it should not call any
+     * client code.
+     */
+    @Override
+    void paintPeer(final Graphics g) {
+        if (!disposed) {
             Dimension size = getPeerSize();
-
             g.setColor( getPeerBackground() );   /* erase the existing button remains */
             g.fillRect(0,0, size.width , size.height);
             paintBorder(g,borderInsets.left,
@@ -239,11 +221,9 @@
 
             viewRect.width = size.width - (contentAreaInsets.left+contentAreaInsets.right);
             viewRect.height = size.height - (contentAreaInsets.top+contentAreaInsets.bottom);
-
             viewRect.x = contentAreaInsets.left;
-            viewRect.y = contentAreaInsets.right;
+            viewRect.y = contentAreaInsets.top;
             String llabel = (label != null) ? label : "";
-
             // layout the text and icon
             String text = SwingUtilities.layoutCompoundLabel(
                                                              fm, llabel, null,
@@ -309,10 +289,9 @@
         else {
             /*** paint the text disabled ***/
             g.setColor(getPeerBackground().brighter());
-
             BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                          textRect.x, textRect.y + fm.getAscent());
-            g.setColor(c.getBackground().darker());
+            g.setColor(getPeerBackground().darker());
             BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemonicIndex,
                                                          textRect.x - 1, textRect.y + fm.getAscent() - 1);
         }
--- a/src/solaris/classes/sun/awt/X11/XCheckboxPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XCheckboxPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -297,40 +297,33 @@
 
         double fsize = (double) checkBoxSize;
         myCheckMark = AffineTransform.getScaleInstance(fsize / MASTER_SIZE, fsize / MASTER_SIZE).createTransformedShape(MASTER_CHECKMARK);
+    }
+    @Override
+    void paintPeer(final Graphics g) {
+        //layout();
+        Dimension size = getPeerSize();
+        Font f = getPeerFont();
+        flush();
+        g.setColor(getPeerBackground());   // erase the existing button
+        g.fillRect(0,0, size.width, size.height);
+        if (label != null) {
+            g.setFont(f);
+            paintText(g, textRect, label);
+        }
 
-    }
-
-    public void paint(Graphics g) {
-        if (g != null) {
-            //layout();
-            Dimension size = getPeerSize();
-            Font f = getPeerFont();
-
-            flush();
-            g.setColor(getPeerBackground());   // erase the existing button
-            g.fillRect(0,0, size.width, size.height);
-
-            if (label != null) {
-                g.setFont(f);
-                paintText(g, textRect, label);
-            }
-
-            if (hasFocus()) {
-                paintFocus(g,
-                           focusRect.x,
-                           focusRect.y,
-                           focusRect.width,
-                           focusRect.height);
-            }
-
-            // Paint the checkbox or radio button
-            if (checkBoxGroup == null) {
-                paintCheckbox(g, cbX, cbY, checkBoxSize, checkBoxSize);
-            }
-            else {
-                paintRadioButton(g, cbX, cbY, checkBoxSize, checkBoxSize);
-            }
-
+        if (hasFocus()) {
+            paintFocus(g,
+                       focusRect.x,
+                       focusRect.y,
+                       focusRect.width,
+                       focusRect.height);
+        }
+        // Paint the checkbox or radio button
+        if (checkBoxGroup == null) {
+            paintCheckbox(g, cbX, cbY, checkBoxSize, checkBoxSize);
+        }
+        else {
+            paintRadioButton(g, cbX, cbY, checkBoxSize, checkBoxSize);
         }
         flush();
     }
--- a/src/solaris/classes/sun/awt/X11/XChoicePeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XChoicePeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -550,10 +550,10 @@
     /**
      * Paint the choice
      */
-    public void paint(Graphics g) {
+    @Override
+    void paintPeer(final Graphics g) {
         flush();
         Dimension size = getPeerSize();
-
         // TODO: when mouse is down over button, widget should be drawn depressed
         g.setColor(getPeerBackground());
         g.fillRect(0, 0, width, height);
@@ -912,16 +912,22 @@
         /*
          * fillRect with current Background color on the whole dropdown list.
          */
-        public void paintBackground(){
-            Graphics g = getGraphics();
-            g.setColor(getPeerBackground());
-            g.fillRect(0, 0, width, height);
+        public void paintBackground() {
+            final Graphics g = getGraphics();
+            if (g != null) {
+                try {
+                    g.setColor(getPeerBackground());
+                    g.fillRect(0, 0, width, height);
+                } finally {
+                    g.dispose();
+                }
+            }
         }
-
         /*
          * 6405689. In some cases we should erase background to eliminate painting
          * artefacts.
          */
+        @Override
         public void repaint() {
             if (!isVisible()) {
                 return;
@@ -931,8 +937,8 @@
             }
             super.repaint();
         }
-
-        public void paint(Graphics g) {
+        @Override
+        public void paintPeer(Graphics g) {
             //System.out.println("UC.paint()");
             Choice choice = (Choice)target;
             Color colors[] = XChoicePeer.this.getGUIcolors();
--- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -38,7 +38,6 @@
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
 import java.awt.Insets;
-import java.awt.KeyboardFocusManager;
 import java.awt.Rectangle;
 import java.awt.SystemColor;
 import java.awt.Toolkit;
@@ -59,15 +58,11 @@
 import java.awt.image.VolatileImage;
 import java.awt.peer.ComponentPeer;
 import java.awt.peer.ContainerPeer;
-import java.awt.peer.LightweightPeer;
 import java.lang.reflect.*;
 import java.security.*;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.Set;
-import java.util.Vector;
 import sun.util.logging.PlatformLogger;
-
 import sun.awt.*;
 import sun.awt.event.IgnorePaintEvent;
 import sun.awt.image.SunVolatileImage;
@@ -428,27 +423,23 @@
     public void disable() {
         setEnabled(false);
     }
-
-    public void paint(Graphics g) {
+    @Override
+    public void paint(final Graphics g) {
+        super.paint(g);
+        // allow target to change the picture
+        target.paint(g);
     }
-    public void repaint(long tm, int x, int y, int width, int height) {
-        repaint();
-    }
-
 
     public Graphics getGraphics() {
         return getGraphics(surfaceData, getPeerForeground(), getPeerBackground(), getPeerFont());
     }
-
-
-
     public void print(Graphics g) {
         // clear rect here to emulate X clears rect before Expose
         g.setColor(target.getBackground());
         g.fillRect(0, 0, target.getWidth(), target.getHeight());
         g.setColor(target.getForeground());
         // paint peer
-        paint(g);
+        paintPeer(g);
         // allow target to change the picture
         target.print(g);
     }
--- a/src/solaris/classes/sun/awt/X11/XLabelPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XLabelPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -85,7 +85,8 @@
      */
     // NOTE: This method is called by privileged threads.
     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
-    public void paint(Graphics g) {
+    @Override
+    void paintPeer(final Graphics g) {
         int textX = 0;
         int textY = 0;
         g.setColor(getPeerBackground());
--- a/src/solaris/classes/sun/awt/X11/XListPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XListPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -363,9 +363,7 @@
             return Math.min(items.size()-1, itemsInWindow()-1);
         }
     }
-
     public void repaintScrollbarRequest(XScrollbar scrollbar) {
-        Graphics g = getGraphics();
         if (scrollbar == hsb)  {
             repaint(PAINT_HSCROLL);
         }
@@ -373,9 +371,6 @@
             repaint(PAINT_VSCROLL);
         }
     }
-
-
-
     /**
      * Overridden for performance
      */
@@ -410,18 +405,20 @@
      * @param distance the distance to copy the source area
      */
     private void repaint(int firstItem, int lastItem, int options, Rectangle source, Point distance) {
-        Graphics g = getGraphics();
-        try {
-            painter.paint(g, firstItem, lastItem, options, source, distance);
-        } finally {
-            g.dispose();
+        final Graphics g = getGraphics();
+        if (g != null) {
+            try {
+                painter.paint(g, firstItem, lastItem, options, source, distance);
+                target.paint(g);
+            } finally {
+                g.dispose();
+            }
         }
     }
-
-    public void paint(Graphics g) {
+    @Override
+    void paintPeer(final Graphics g) {
         painter.paint(g, getFirstVisibleItem(), getLastVisibleItem(), PAINT_ALL);
     }
-
     public boolean isFocusable() { return true; }
 
     // TODO: share/promote the Focus methods?
--- a/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -415,7 +415,7 @@
      * Overriden XWindow painting & printing
      *
      ************************************************/
-    public void paint(Graphics g) {
+    public void paintPeer(Graphics g) {
         resetColors();
         /* Calculate menubar dimension. */
         int width = getWidth();
--- a/src/solaris/classes/sun/awt/X11/XMenuWindow.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XMenuWindow.java	Wed Jul 27 22:42:19 2011 -0700
@@ -432,9 +432,9 @@
     /**
      * Paints menu window
      */
-    public void paint(Graphics g) {
+    @Override
+    public void paintPeer(Graphics g) {
         resetColors();
-
         int width = getWidth();
         int height = getHeight();
 
--- a/src/solaris/classes/sun/awt/X11/XPanelPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XPanelPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -60,14 +60,13 @@
     public Insets getInsets() {
         return new Insets(0, 0, 0, 0);
     }
-
     public void paint(Graphics g) {
         super.paint(g);
-        /*      SunGraphicsCallback.PaintHeavyweightComponentsCallback.getInstance().
-                runComponents(((Container)target).getComponents(), g,
-                SunGraphicsCallback.LIGHTWEIGHTS |
-                SunGraphicsCallback.HEAVYWEIGHTS);
-        */ }
+        SunGraphicsCallback.PaintHeavyweightComponentsCallback.getInstance().
+            runComponents(((Container)target).getComponents(), g,
+                          SunGraphicsCallback.LIGHTWEIGHTS |
+                          SunGraphicsCallback.HEAVYWEIGHTS);
+    }
     public void print(Graphics g) {
         super.print(g);
         SunGraphicsCallback.PrintHeavyweightComponentsCallback.getInstance().
--- a/src/solaris/classes/sun/awt/X11/XRepaintArea.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XRepaintArea.java	Wed Jul 27 22:42:19 2011 -0700
@@ -53,9 +53,9 @@
      */
     protected void updateComponent(Component comp, Graphics g) {
         if (comp != null) {
-            ComponentPeer peer = comp.getPeer();
+            final XComponentPeer peer = (XComponentPeer) comp.getPeer();
             if (peer != null) {
-                peer.paint(g);
+                peer.paintPeer(g);
             }
             super.updateComponent(comp, g);
         }
@@ -66,9 +66,9 @@
      */
     protected void paintComponent(Component comp, Graphics g) {
         if (comp != null) {
-            ComponentPeer peer = comp.getPeer();
+            final XComponentPeer peer = (XComponentPeer) comp.getPeer();
             if (peer != null) {
-                peer.paint(g);
+                peer.paintPeer(g);
             }
             super.paintComponent(comp, g);
         }
--- a/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -29,6 +29,8 @@
 import java.awt.event.*;
 import java.awt.peer.*;
 import java.lang.reflect.*;
+
+import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 
 class XScrollPanePeer extends XComponentPeer implements ScrollPanePeer, XScrollbarClient {
@@ -41,9 +43,7 @@
     public final static int     VERTICAL = 1 << 0;
     public final static int     HORIZONTAL = 1 << 1;
 
-    private static Method m_setValue;
     static {
-        m_setValue = SunToolkit.getMethod(ScrollPaneAdjustable.class, "setTypedValue", new Class[] {Integer.TYPE, Integer.TYPE});
         SCROLLBAR = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth");
     }
 
@@ -293,10 +293,12 @@
                 setAdjustableValue(hadj, hsb.getValue(), type);
                 sx = -(hsb.getValue());
                 Graphics g = getGraphics();
-                try {
-                    paintHorScrollbar(g, colors, true);
-                } finally {
-                    g.dispose();
+                if (g != null) {
+                    try {
+                        paintHorScrollbar(g, colors, true);
+                    } finally {
+                        g.dispose();
+                    }
                 }
             }
             if ((flag & VERTICAL) != 0) {
@@ -305,36 +307,38 @@
                 setAdjustableValue(vadj, vsb.getValue(), type);
                 sy = -(vsb.getValue());
                 Graphics g = getGraphics();
-                try {
-                    paintVerScrollbar(g, colors, true);
-                } finally {
-                    g.dispose();
+                if (g != null) {
+                    try {
+                        paintVerScrollbar(g, colors, true);
+                    } finally {
+                        g.dispose();
+                    }
                 }
             }
         }
         c.move(sx, sy);
     }
 
-    void setAdjustableValue(ScrollPaneAdjustable adj, int value, int type) {
-        try {
-            m_setValue.invoke(adj, new Object[] {Integer.valueOf(value), Integer.valueOf(type)});
-        } catch (IllegalAccessException iae) {
-            adj.setValue(value);
-        } catch (IllegalArgumentException iae2) {
-            adj.setValue(value);
-        } catch (InvocationTargetException ite) {
-            adj.setValue(value);
-            ite.getCause().printStackTrace();
+    private void setAdjustableValue(final ScrollPaneAdjustable adj, final int value,
+                            final int type) {
+        AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj, value,
+                                                                    type);
+    }
+    @Override
+    void paintPeer(final Graphics g) {
+        final Color[] colors = getGUIcolors();
+        g.setColor(colors[BACKGROUND_COLOR]);
+        final int h = height - hsbSpace;
+        final int w = width - vsbSpace;
+        g.fillRect(0, 0, w, h);
+        // paint rectangular region between scrollbars
+        g.fillRect(w, h, vsbSpace, hsbSpace);
+        if (MARGIN > 0) {
+            draw3DRect(g, colors, 0, 0, w - 1, h - 1, false);
         }
+        paintScrollBars(g, colors);
     }
-
-
-    public void paint(Graphics g) {
-        paintComponent(g);
-    }
-
-
-    void paintScrollBars(Graphics g, Color[] colors) {
+    private void paintScrollBars(Graphics g, Color[] colors) {
         if (vsbSpace > 0) {
             paintVerScrollbar(g, colors, true);
             // paint the whole scrollbar
@@ -345,51 +349,32 @@
             // paint the whole scrollbar
         }
     }
-
-   void repaintScrollBars() {
-       Graphics g = getGraphics();
-       Color colors[] = getGUIcolors();
-       if (g != null) {
-           paintScrollBars(g,colors);
-       }
-       g.dispose();
-   }
-
+    void repaintScrollBars() {
+        Graphics g = getGraphics();
+        Color colors[] = getGUIcolors();
+        if (g != null) {
+            try {
+                paintScrollBars(g, colors);
+            } finally {
+                g.dispose();
+            }
+        }
+    }
     public void repaintScrollbarRequest(XScrollbar sb) {
-       Graphics g = getGraphics();
-       Color colors[] = getGUIcolors();
-       if (g != null) {
-           if (sb ==  vsb)  {
-               paintVerScrollbar(g,colors,true);
-           }
-           else if (sb ==  hsb) {
-               paintHorScrollbar(g,colors,true);
-           }
-       }
+        Graphics g = getGraphics();
+        Color colors[] = getGUIcolors();
+        if (g != null) {
+            try {
+                if (sb == vsb) {
+                    paintVerScrollbar(g, colors, true);
+                } else if (sb == hsb) {
+                    paintHorScrollbar(g, colors, true);
+                }
+            } finally {
+                g.dispose();
+            }
+        }
     }
-
-    /**
-     * Paint the scrollpane.
-     */
-    public void paintComponent(Graphics g) {
-
-        Color colors[] = getGUIcolors();
-        g.setColor(colors[BACKGROUND_COLOR]);
-        int h = height - hsbSpace;
-        int w = width - vsbSpace;
-
-        g.fillRect(0, 0, w, h);
-
-        // paint rectangular region between scrollbars
-        g.fillRect(w, h, vsbSpace, hsbSpace);
-
-        if (MARGIN > 0) {
-            draw3DRect(g, colors, 0, 0, w - 1, h - 1, false);
-        }
-
-        paintScrollBars(g,colors);
-    }
-
     public void handleEvent(java.awt.AWTEvent e) {
         super.handleEvent(e);
 
--- a/src/solaris/classes/sun/awt/X11/XScrollbarPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XScrollbarPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -90,18 +90,12 @@
             ? new Dimension(getDefaultDimension(), DEFAULT_LENGTH)
                 : new Dimension(DEFAULT_LENGTH, getDefaultDimension());
     }
-
-    public void repaint() {
-        Graphics g = getGraphics();
-        if (g != null) paint(g);
-    }
-
     /**
      * Paint the scrollbar.
      */
-    public void paint(Graphics g) {
-        Scrollbar sb = (Scrollbar)target;
-        Color colors[] = getGUIcolors();
+    @Override
+    void paintPeer(final Graphics g) {
+        final Color[] colors = getGUIcolors();
         g.setColor(colors[BACKGROUND_COLOR]);
         tsb.paint(g, colors, true);
         // paint the whole scrollbar
--- a/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -185,11 +185,8 @@
      */
     @Override
     public void pSetCursor(Cursor cursor, boolean ignoreSubComponents) {
-        Point onScreen = getLocationOnScreen();
         if (ignoreSubComponents ||
-            javaMouseEventHandler == null ||
-            onScreen == null)
-        {
+            javaMouseEventHandler == null) {
             super.pSetCursor(cursor, true);
             return;
         }
@@ -197,6 +194,7 @@
         Point cursorPos = new Point();
         ((XGlobalCursorManager)XGlobalCursorManager.getCursorManager()).getCursorPos(cursorPos);
 
+        final Point onScreen = getLocationOnScreen();
         Point localPoint = new Point(cursorPos.x - onScreen.x, cursorPos.y - onScreen.y );
 
         javaMouseEventHandler.setPointerToUnderPoint(localPoint);
@@ -300,15 +298,14 @@
      * Paint the component
      * this method is called when the repaint instruction has been used
      */
-
     public void repaint() {
         if (textPane  != null)  {
             //textPane.validate();
             textPane.repaint();
         }
     }
-
-    public void paint(Graphics g) {
+    @Override
+    void paintPeer(final Graphics g) {
         if (textPane  != null)  {
             textPane.paint(g);
         }
--- a/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -370,12 +370,11 @@
     public void repaint() {
         if (xtext  != null) xtext.repaint();
     }
-
-    public void paint(Graphics g) {
+    @Override
+    void paintPeer(final Graphics g) {
         if (xtext  != null) xtext.paint(g);
     }
 
-
     public void print(Graphics g) {
         if (xtext != null) {
             xtext.print(g);
--- a/src/solaris/classes/sun/awt/X11/XWarningWindow.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XWarningWindow.java	Wed Jul 27 22:42:19 2011 -0700
@@ -241,16 +241,19 @@
     Font getFont () {
         return ownerWindow.getFont();
     }
+
+    @Override
     public void repaint() {
-        Rectangle bounds = getBounds();
-        Graphics g = getGraphics();
-        try {
-            paint(g, 0, 0, bounds.width, bounds.height);
-        } finally {
-            g.dispose();
+        final Rectangle bounds = getBounds();
+        final Graphics g = getGraphics();
+        if (g != null) {
+            try {
+                paint(g, 0, 0, bounds.width, bounds.height);
+            } finally {
+                g.dispose();
+            }
         }
     }
-
     @Override
     public void handleExposeEvent(XEvent xev) {
         super.handleExposeEvent(xev);
@@ -263,11 +266,13 @@
         SunToolkit.executeOnEventHandlerThread(target,
                 new Runnable() {
                     public void run() {
-                        Graphics g = getGraphics();
-                        try {
-                            paint(g, x, y, width, height);
-                        } finally {
-                            g.dispose();
+                        final Graphics g = getGraphics();
+                        if (g != null) {
+                            try {
+                                paint(g, x, y, width, height);
+                            } finally {
+                                g.dispose();
+                            }
                         }
                     }
                 });
--- a/src/solaris/classes/sun/awt/X11/XWindow.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/solaris/classes/sun/awt/X11/XWindow.java	Wed Jul 27 22:42:19 2011 -0700
@@ -502,9 +502,8 @@
     public boolean isEmbedded() {
         return embedded;
     }
-
     public  void repaint(int x,int y, int width, int height) {
-        if (!isVisible()) {
+        if (!isVisible() || getWidth() == 0 || getHeight() == 0) {
             return;
         }
         Graphics g = getGraphics();
@@ -517,12 +516,11 @@
             }
         }
     }
-
-    public  void repaint() {
-        if (!isVisible()) {
+    void repaint() {
+        if (!isVisible() || getWidth() == 0 || getHeight() == 0) {
             return;
         }
-        Graphics g = getGraphics();
+        final Graphics g = getGraphics();
         if (g != null) {
             try {
                 paint(g);
@@ -531,10 +529,13 @@
             }
         }
     }
-
-    void paint(Graphics g) {
+    public void paint(final Graphics g) {
+        // paint peer
+        paintPeer(g);
     }
 
+    void paintPeer(final Graphics g) {
+    }
     //used by Peers to avoid flickering withing paint()
     protected void flush(){
         XToolkit.awtLock();
--- a/src/windows/classes/sun/awt/windows/WMenuItemPeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/classes/sun/awt/windows/WMenuItemPeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -183,7 +183,9 @@
      */
     private static native void initIDs();
 
-    // Needed for MenuComponentPeer.
-    public void setFont(Font f) {
+    private native void _setFont(Font f);
+
+    public void setFont(final Font f) {
+        _setFont(f);
     }
 }
--- a/src/windows/classes/sun/awt/windows/WScrollPanePeer.java	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/classes/sun/awt/windows/WScrollPanePeer.java	Wed Jul 27 22:42:19 2011 -0700
@@ -27,6 +27,8 @@
 import java.awt.*;
 import java.awt.event.AdjustmentEvent;
 import java.awt.peer.ScrollPanePeer;
+
+import sun.awt.AWTAccessor;
 import sun.awt.PeerEvent;
 
 import sun.util.logging.PlatformLogger;
@@ -169,8 +171,6 @@
         }
     }
 
-    native void setTypedValue(ScrollPaneAdjustable adjustable, int newpos, int type);
-
     /*
      * Runnable for the ScrollEvent that performs the adjustment.
      */
@@ -247,8 +247,9 @@
             // Fix for 4075484 - consider type information when creating AdjustmentEvent
             // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
             // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
-            // Because ScrollPaneAdjustable is in another package we should call it through native code.
-            setTypedValue(adj, newpos, type);
+            AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
+                                                                        newpos,
+                                                                        type);
 
             // Paint the exposed area right away.  To do this - find
             // the heavyweight ancestor of the scroll child.
--- a/src/windows/native/sun/windows/awt_Choice.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_Choice.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -396,12 +396,6 @@
 
     DASSERT(::IsWindow(hwnd));
 
-    // This branch is required for the proper work of AwtComponent::GetComponent() method
-    // while hovering drop-down list
-    if (message == WmAwtIsComponent) {
-        return (LRESULT)TRUE;
-    }
-
     switch (message) {
         case WM_LBUTTONDOWN: {
             DWORD curPos = ::GetMessagePos();
--- a/src/windows/native/sun/windows/awt_Component.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_Component.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -364,6 +364,7 @@
     AwtComponent *component =
         (AwtComponent *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
     DASSERT(!component || !IsBadReadPtr(component, sizeof(AwtComponent)) );
+    DASSERT(!component || component->GetHWnd() == hWnd );
     return component;
 }
 
--- a/src/windows/native/sun/windows/awt_Menu.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_Menu.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -119,6 +119,41 @@
     return menu;
 }
 
+void AwtMenu::UpdateLayout()
+{
+    UpdateLayout(GetHMenu());
+    RedrawMenuBar();
+}
+
+void AwtMenu::UpdateLayout(const HMENU hmenu)
+{
+    const int nMenuItemCount = ::GetMenuItemCount(hmenu);
+    static MENUITEMINFO  mii;
+    for (int idx = 0; idx < nMenuItemCount; ++idx) {
+        memset(&mii, 0, sizeof(mii));
+        mii.cbSize = sizeof(mii);
+        mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID
+                  | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE;
+        if (::GetMenuItemInfo(hmenu, idx, TRUE, &mii)) {
+            VERIFY(::RemoveMenu(hmenu, idx, MF_BYPOSITION));
+            VERIFY(::InsertMenuItem(hmenu, idx, TRUE, &mii));
+            if (mii.hSubMenu !=  NULL) {
+                UpdateLayout(mii.hSubMenu);
+            }
+        }
+    }
+}
+
+void AwtMenu::UpdateContainerLayout()
+{
+    AwtMenu* menu = GetMenuContainer();
+    if (menu != NULL) {
+        menu->UpdateLayout();
+    } else {
+        UpdateLayout();
+    }
+}
+
 AwtMenuBar* AwtMenu::GetMenuBar() {
     return (GetMenuContainer() == NULL) ? NULL : GetMenuContainer()->GetMenuBar();
 }
--- a/src/windows/native/sun/windows/awt_Menu.h	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_Menu.h	Wed Jul 27 22:42:19 2011 -0700
@@ -72,6 +72,8 @@
     virtual AwtMenuBar* GetMenuBar();
 
     void AddSeparator();
+    virtual void UpdateContainerLayout();
+    void UpdateLayout();
     virtual void AddItem(AwtMenuItem *item);
     virtual void DeleteItem(UINT index);
 
@@ -103,6 +105,7 @@
     virtual void RemoveCmdID() { /* do nothing */ }
 
 private:
+    void UpdateLayout(const HMENU hmenu);
     HMENU    m_hMenu;
 };
 
--- a/src/windows/native/sun/windows/awt_MenuBar.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_MenuBar.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -198,7 +198,15 @@
     if (hOwnerWnd != NULL) {
         VERIFY(::InvalidateRect(hOwnerWnd,0,TRUE));
     }
-    ::DrawMenuBar(GetOwnerHWnd());
+    RedrawMenuBar();
+}
+
+/**
+ * If the menu changes after the system has created the window,
+ * this function must be called to draw the changed menu bar.
+ */
+void AwtMenuBar::RedrawMenuBar() {
+    VERIFY(::DrawMenuBar(GetOwnerHWnd()));
 }
 
 LRESULT AwtMenuBar::WinThreadExecProc(ExecuteArgs * args)
@@ -232,7 +240,7 @@
     if (::IsWindow(m->GetOwnerHWnd()))
     {
         /* The menu was already created and added during peer creation -- redraw */
-        ::DrawMenuBar(m->GetOwnerHWnd());
+        m->RedrawMenuBar();
     }
 ret:
     env->DeleteGlobalRef(self);
--- a/src/windows/native/sun/windows/awt_MenuBar.h	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_MenuBar.h	Wed Jul 27 22:42:19 2011 -0700
@@ -65,6 +65,7 @@
     INLINE AwtFrame* GetFrame() { return m_frame; }
 
     virtual HWND GetOwnerHWnd();
+    virtual void RedrawMenuBar();
 
     AwtMenuItem* GetItem(jobject target, long index);
     int CountItem(jobject menuBar);
--- a/src/windows/native/sun/windows/awt_MenuItem.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_MenuItem.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -626,7 +626,7 @@
     mii.dwTypeData = (LPTSTR)(*sb);
 
     // find index by menu item id
-    int nMenuItemCount = ::GetMenuItemCount(hMenu);;
+    int nMenuItemCount = ::GetMenuItemCount(hMenu);
     int idx;
     for (idx = 0; (idx < nMenuItemCount); idx++) {
         memset(&mii1, 0, sizeof(MENUITEMINFO));
@@ -639,10 +639,7 @@
     ::RemoveMenu(hMenu, idx, MF_BYPOSITION);
     ::InsertMenuItem(hMenu, idx, TRUE, &mii);
 
-    // Redraw menu bar if it was affected.
-    if (menu->GetMenuBar() == menu) {
-        ::DrawMenuBar(menu->GetOwnerHWnd());
-    }
+    RedrawMenuBar();
 }
 
 void AwtMenuItem::Enable(BOOL isEnabled)
@@ -658,10 +655,7 @@
                             MF_BYCOMMAND | (isEnabled ? MF_ENABLED : MF_GRAYED))
            != 0xFFFFFFFF);
 
-    // Redraw menu bar if it was affected.
-    if (menu->GetMenuBar() == menu) {
-        ::DrawMenuBar(menu->GetOwnerHWnd());
-    }
+    RedrawMenuBar();
 }
 
 void AwtMenuItem::SetState(BOOL isChecked)
@@ -676,23 +670,31 @@
                            MF_BYCOMMAND | (isChecked ? MF_CHECKED : MF_UNCHECKED))
            != 0xFFFFFFFF);
 
-    // Redraw menu bar if it was affected.
-    if (menu->GetMenuBar() == menu) {
-        ::DrawMenuBar(menu->GetOwnerHWnd());
+    RedrawMenuBar();
+}
+
+/**
+ * If the menu changes after the system has created the window,
+ * this function must be called to draw the changed menu bar.
+ */
+void AwtMenuItem::RedrawMenuBar() {
+    AwtMenu* menu = GetMenuContainer();
+    if (menu != NULL && menu->GetMenuBar() == menu){
+        menu->RedrawMenuBar();
+    }
+}
+
+void AwtMenuItem::UpdateContainerLayout() {
+    AwtMenu* menu = GetMenuContainer();
+    if (menu != NULL) {
+        DASSERT(menu != NULL && GetID() >= 0);
+        menu->UpdateLayout();
     }
 }
 
 LRESULT AwtMenuItem::WinThreadExecProc(ExecuteArgs * args)
 {
     switch( args->cmdId ) {
-        case MENUITEM_SETLABEL:
-        {
-            LPCTSTR sb = (LPCTSTR)args->param1;
-            DASSERT(!IsBadStringPtr(sb, 20));
-            this->SetLabel(sb);
-        }
-        break;
-
         case MENUITEM_ENABLE:
         {
             BOOL        isEnabled = (BOOL)args->param1;
@@ -714,75 +716,98 @@
     return 0L;
 }
 
-void AwtMenuItem::_SetLabel(void *param)
-{
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+void AwtMenuItem::_SetLabel(void *param) {
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
-    SetLabelStruct *sls = (SetLabelStruct *)param;
-    jobject self = sls->menuitem;
-    jstring label = sls->label;
+        SetLabelStruct *sls = (SetLabelStruct *)param;
+        jobject self = sls->menuitem;
+        jstring label = sls->label;
 
-    int badAlloc = 0;
-    AwtMenuItem *m = NULL;
+        int badAlloc = 0;
+        AwtMenuItem *m = NULL;
 
-    PDATA pData;
-    JNI_CHECK_PEER_GOTO(self, ret);
-    m = (AwtMenuItem *)pData;
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+        m = (AwtMenuItem *)pData;
 //    if (::IsWindow(m->GetOwnerHWnd()))
-    {
-        // fix for bug 4251036 MenuItem setLabel(null/"") behaves differently
-        // under Win32 and Solaris
-        jstring empty = NULL;
-        if (JNU_IsNull(env, label))
         {
-            empty = JNU_NewStringPlatform(env, TEXT(""));
-        }
-        LPCTSTR labelPtr;
-        if (empty != NULL)
-        {
-            labelPtr = JNU_GetStringPlatformChars(env, empty, 0);
-        }
-        else
-        {
-            labelPtr = JNU_GetStringPlatformChars(env, label, 0);
-        }
-        if (labelPtr == NULL)
-        {
-            badAlloc = 1;
-        }
-        else
-        {
-            ExecuteArgs args;
-            args.cmdId = MENUITEM_SETLABEL;
-            args.param1 = (LPARAM)labelPtr;
-            m->WinThreadExecProc(&args);
+            // fix for bug 4251036 MenuItem setLabel(null/"") behaves differently
+            // under Win32 and Solaris
+            jstring empty = NULL;
+            if (JNU_IsNull(env, label))
+            {
+                empty = JNU_NewStringPlatform(env, TEXT(""));
+            }
+            LPCTSTR labelPtr;
             if (empty != NULL)
             {
-                JNU_ReleaseStringPlatformChars(env, empty, labelPtr);
+                labelPtr = JNU_GetStringPlatformChars(env, empty, 0);
             }
             else
             {
-                JNU_ReleaseStringPlatformChars(env, label, labelPtr);
+                labelPtr = JNU_GetStringPlatformChars(env, label, 0);
+            }
+            if (labelPtr == NULL)
+            {
+                badAlloc = 1;
+            }
+            else
+            {
+                DASSERT(!IsBadStringPtr(labelPtr, 20));
+                m->SetLabel(labelPtr);
+                if (empty != NULL)
+                {
+                    JNU_ReleaseStringPlatformChars(env, empty, labelPtr);
+                }
+                else
+                {
+                    JNU_ReleaseStringPlatformChars(env, label, labelPtr);
+                }
+            }
+            if (empty != NULL)
+            {
+                env->DeleteLocalRef(empty);
             }
         }
-        if (empty != NULL)
-        {
-            env->DeleteLocalRef(empty);
-        }
-    }
 
 ret:
-    env->DeleteGlobalRef(self);
-    if (label != NULL)
-    {
-        env->DeleteGlobalRef(label);
+        env->DeleteGlobalRef(self);
+        if (label != NULL)
+        {
+            env->DeleteGlobalRef(label);
+        }
+
+        delete sls;
+
+        if (badAlloc)
+        {
+            throw std::bad_alloc();
+        }
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetLabel, param);
     }
+}
 
-    delete sls;
+void AwtMenuItem::_UpdateLayout(void *param)
+{
+    if (AwtToolkit::IsMainThread()) {
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 
-    if (badAlloc)
-    {
-        throw std::bad_alloc();
+        jobject self = (jobject)param;
+
+        AwtMenuItem *m = NULL;
+
+        PDATA pData;
+        JNI_CHECK_PEER_GOTO(self, ret);
+
+        m = (AwtMenuItem *)pData;
+
+        m->UpdateContainerLayout();
+ret:
+        env->DeleteGlobalRef(self);
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_UpdateLayout, param);
     }
 }
 
@@ -883,8 +908,8 @@
 
 /*
  * Class:     sun_awt_windows_WMenuItemPeer
- * Method:    _setLabel
- * Signature: (Ljava/lang/String;)V
+ * Method:    initIDs
+ * Signature: ()V
  */
 JNIEXPORT void JNICALL
 Java_sun_awt_windows_WMenuItemPeer_initIDs(JNIEnv *env, jclass cls)
@@ -927,6 +952,26 @@
 
 /*
  * Class:     sun_awt_windows_WMenuItemPeer
+ * Method:    _setFont
+ * Signature: (Ljava/awt/Font;)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WMenuItemPeer__1setFont(JNIEnv *env, jobject self, jobject)
+{
+    TRY;
+
+    jobject selfGlobalRef = env->NewGlobalRef(self);
+
+    // Current implementation of AwtMenuItem get font attribute from the peer
+    // directly, so we ignore it here, but update current menu layout.
+    AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_UpdateLayout, selfGlobalRef);
+    // selfGlobalRef is deleted in _UpdateLayout
+
+    CATCH_BAD_ALLOC;
+}
+
+/*
+ * Class:     sun_awt_windows_WMenuItemPeer
  * Method:    create
  * Signature: (Lsun/awt/windows/WMenuPeer;)V
  */
--- a/src/windows/native/sun/windows/awt_MenuItem.h	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_MenuItem.h	Wed Jul 27 22:42:19 2011 -0700
@@ -48,7 +48,6 @@
 public:
     // id's for methods executed on toolkit thread
     enum {
-        MENUITEM_SETLABEL,
         MENUITEM_ENABLE,
         MENUITEM_SETSTATE,
         MENUITEM_LAST
@@ -78,7 +77,6 @@
 
     virtual LPCTSTR GetClassName();
 
-    void AwtMenuItem::LinkObjects(jobject peer);
     static AwtMenuItem* Create(jobject self, jobject menu);
 
     INLINE AwtMenu* GetMenuContainer() { return m_menuContainer; }
@@ -148,6 +146,8 @@
 
     void SetLabel(LPCTSTR sb);
     virtual void Enable(BOOL isEnabled);
+    virtual void UpdateContainerLayout();
+    virtual void RedrawMenuBar();
     void SetState(BOOL isChecked);
 
     /*
@@ -163,6 +163,7 @@
 
     // invoked on Toolkit thread
     static void _SetLabel(void *param);
+    static void _UpdateLayout(void *param);
 
 protected:
     AwtMenu* m_menuContainer;  /* The menu object containing this item */
--- a/src/windows/native/sun/windows/awt_PrintJob.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_PrintJob.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -4137,7 +4137,7 @@
 
     AwtPrintDialog::controlID =
       env->GetFieldID(cls, "pjob", "Ljava/awt/print/PrinterJob;");
-    jclass printDialogPeerClass = env->FindClass("Lsun/awt/windows/WPrintDialogPeer;");
+    jclass printDialogPeerClass = env->FindClass("sun/awt/windows/WPrintDialogPeer");
     AwtPrintDialog::setHWndMID =
       env->GetMethodID(printDialogPeerClass, "setHWnd", "(J)V");
 
--- a/src/windows/native/sun/windows/awt_ScrollPane.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_ScrollPane.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -808,29 +808,4 @@
     CATCH_BAD_ALLOC;
 }
 
-/*
- * Class:     sun_awt_windows_WScrollPanePeer
- * Method:    setTypedValue
- * Signature: (Ljava/awt/ScrollPaneAdjustable;II)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_windows_WScrollPanePeer_setTypedValue(JNIEnv *env, jobject peer, jobject adjustable, jint value, jint type)
-{
-    // need this global ref to make the class unloadable (see 6500204)
-    static jclass scrollPaneAdj;
-    static jmethodID setTypedValueMID = 0;
-    if (setTypedValueMID == NULL) {
-        jclass clazz = env->FindClass("java/awt/ScrollPaneAdjustable");
-        if (safe_ExceptionOccurred(env)) {
-            env->ExceptionDescribe();
-            env->ExceptionClear();
-        }
-        setTypedValueMID = env->GetMethodID(clazz, "setTypedValue", "(II)V");
-        scrollPaneAdj = (jclass) env->NewGlobalRef(clazz);
-        env->DeleteLocalRef(clazz);
-        DASSERT(setTypedValueMID != NULL);
-    }
-    env->CallVoidMethod(adjustable, setTypedValueMID, value, type);
-}
-
 } /* extern "C" */
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp	Tue Jul 26 21:34:25 2011 +0200
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp	Wed Jul 27 22:42:19 2011 -0700
@@ -1444,7 +1444,6 @@
     AwtComponent* mouseComp =
         AwtComponent::GetComponent(hWndFromPoint);
     // Need extra copies for non-client area issues
-    AwtComponent* mouseWheelComp = mouseComp;
     HWND hWndForWheel = hWndFromPoint;
 
     // If the point under the mouse isn't in the client area,
@@ -1510,9 +1509,9 @@
      */
 
     if (msg.message == WM_MOUSEWHEEL &&
-        mouseWheelComp != NULL) { //i.e. mouse is over client area for this
-                                  //window
-        msg.hwnd = hWndForWheel;
+        AwtToolkit::MainThread() == ::GetWindowThreadProcessId(hWndForWheel, NULL)) {
+            //i.e. mouse is over client area for this window
+            msg.hwnd = hWndForWheel;
     }
 
     /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java	Wed Jul 27 22:42:19 2011 -0700
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 7050935
+  @summary closed/java/awt/Choice/WheelEventsConsumed/WheelEventsConsumed.html fails on win32
+  @author Oleg Pekhovskiy: area=awt-choice
+  @run main ChoiceMouseWheelTest
+*/
+
+import test.java.awt.regtesthelpers.Util;
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class ChoiceMouseWheelTest extends Frame {
+
+    private volatile boolean itemChanged = false;
+    private volatile boolean wheelMoved = false;
+    private volatile boolean frameExited = false;
+
+    public static void main(String[] args) {
+        new ChoiceMouseWheelTest();
+    }
+
+    ChoiceMouseWheelTest() {
+        super("ChoiceMouseWheelTest");
+        setLayout(new FlowLayout());
+
+        Choice choice = new Choice();
+
+        addWindowListener(new WindowAdapter() {
+            @Override
+            public void windowClosing(WindowEvent e) {
+                System.exit(0);
+            }
+        });
+
+        for(Integer i = 0; i < 50; i++) {
+            choice.add(i.toString());
+        }
+
+        choice.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                itemChanged = true;
+            }
+        });
+        choice.addMouseWheelListener(new MouseWheelListener() {
+            public void mouseWheelMoved(MouseWheelEvent e) {
+                wheelMoved = true;
+            }
+        });
+
+        addMouseListener(new MouseAdapter() {
+            @Override
+            public void mouseExited(MouseEvent e) {
+                frameExited = true;
+            }
+        });
+
+        add(choice);
+        setSize(200, 300);
+        setVisible(true);
+        toFront();
+
+        try {
+            Robot robot = new Robot();
+            robot.setAutoDelay(20);
+            Util.waitForIdle(robot);
+
+            Point pt = choice.getLocationOnScreen();
+            Dimension size = choice.getSize();
+            int x = pt.x + size.width / 3;
+            robot.mouseMove(x, pt.y + size.height / 2);
+
+            // Test mouse wheel over the choice
+            String name = Toolkit.getDefaultToolkit().getClass().getName();
+            if(!name.equals("sun.awt.X11.XToolkit")) { // mouse wheel doesn't work for the choice on X11, so skip it
+                robot.mouseWheel(1);
+                Util.waitForIdle(robot);
+
+                if(!wheelMoved || !itemChanged) {
+                    throw new RuntimeException("Mouse Wheel over the choice failed!");
+                }
+            }
+
+            // Test mouse wheel over the drop-down list
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            Util.waitForIdle(robot);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            Util.waitForIdle(robot);
+
+            int y = getLocationOnScreen().y + getSize().height;
+            while(!frameExited && y >= 0) { // move to the bottom of drop-down list
+                robot.mouseMove(x, --y);
+                Util.waitForIdle(robot);
+            }
+
+            if(x < 0) {
+                throw new RuntimeException("Could not enter drop-down list!");
+            }
+
+            y -= choice.getHeight() / 2;
+            robot.mouseMove(x, y); // move to the last visible item in the drop-down list
+            Util.waitForIdle(robot);
+
+            robot.mouseWheel(choice.getItemCount()); // wheel to the last item
+            Util.waitForIdle(robot);
+
+            // click the last item
+            itemChanged = false;
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            Util.waitForIdle(robot);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            Util.waitForIdle(robot);
+
+            if(!itemChanged || choice.getSelectedIndex() != choice.getItemCount() - 1) {
+                throw new RuntimeException("Mouse Wheel scroll position error!");
+            }
+
+            System.exit(0);
+
+        } catch (AWTException e) {
+            throw new RuntimeException("AWTException occurred - problem creating robot!");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Component/PaintAll/PaintAll.java	Wed Jul 27 22:42:19 2011 -0700
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Panel;
+import java.awt.ScrollPane;
+import java.awt.Scrollbar;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+
+/*
+  @test
+  @bug 6596915
+  @summary Test Component.paintAll() method
+  @author sergey.bylokhov@oracle.com: area=awt.component
+  @run main PaintAll
+*/
+public class PaintAll {
+
+    private static volatile boolean lwPainted;
+    private static volatile boolean buttonPainted;
+    private static volatile boolean canvasPainted;
+    private static volatile boolean checkboxPainted;
+    private static volatile boolean choicePainted;
+    private static volatile boolean containerPainted;
+    private static volatile boolean framePainted;
+    private static volatile boolean labelPainted;
+    private static volatile boolean listPainted;
+    private static volatile boolean panelPainted;
+    private static volatile boolean scrollbarPainted;
+    private static volatile boolean scrollPanePainted;
+    private static volatile boolean textAreaPainted;
+    private static volatile boolean textFieldPainted;
+
+    private static final Button buttonStub = new Button() {
+        @Override
+        public void paint(final Graphics g) {
+            buttonPainted = true;
+        }
+    };
+
+    private static final Canvas canvasStub = new Canvas() {
+        @Override
+        public void paint(final Graphics g) {
+            canvasPainted = true;
+        }
+    };
+
+    private static final Checkbox checkboxStub = new Checkbox() {
+        @Override
+        public void paint(final Graphics g) {
+            checkboxPainted = true;
+        }
+    };
+
+    private static final Choice choiceStub = new Choice() {
+        @Override
+        public void paint(final Graphics g) {
+            choicePainted = true;
+        }
+    };
+
+    private static final Component lwComponentStub = new Component() {
+        @Override
+        public void paint(final Graphics g) {
+            lwPainted = true;
+        }
+    };
+
+    private static final Container containerStub = new Container() {
+        @Override
+        public void paint(final Graphics g) {
+            containerPainted = true;
+        }
+    };
+
+    private static final Frame frame = new Frame() {
+        @Override
+        public void paint(final Graphics g) {
+            super.paint(g);
+            framePainted = true;
+        }
+    };
+
+    private static final Label labelStub = new Label() {
+        @Override
+        public void paint(final Graphics g) {
+            labelPainted = true;
+        }
+    };
+
+    private static final List listStub = new List() {
+        @Override
+        public void paint(final Graphics g) {
+            listPainted = true;
+        }
+    };
+
+    private static final Panel panelStub = new Panel() {
+        @Override
+        public void paint(final Graphics g) {
+            panelPainted = true;
+        }
+    };
+
+    private static final Scrollbar scrollbarStub = new Scrollbar() {
+        @Override
+        public void paint(final Graphics g) {
+            scrollbarPainted = true;
+        }
+    };
+
+    private static final ScrollPane scrollPaneStub = new ScrollPane() {
+        @Override
+        public void paint(final Graphics g) {
+            scrollPanePainted = true;
+        }
+    };
+
+    private static final TextArea textAreaStub = new TextArea() {
+        @Override
+        public void paint(final Graphics g) {
+            textAreaPainted = true;
+        }
+    };
+
+    private static final TextField textFieldStub = new TextField() {
+        @Override
+        public void paint(final Graphics g) {
+            textFieldPainted = true;
+        }
+    };
+
+    public static void main(final String[] args) throws Exception {
+        //Frame initialisation
+        final BufferedImage graphicsProducer =
+                new BufferedImage(BufferedImage.TYPE_INT_ARGB, 1, 1);
+
+        final Graphics g = graphicsProducer.getGraphics();
+
+        frame.setLayout(new GridLayout());
+        frame.add(buttonStub);
+        frame.add(canvasStub);
+        frame.add(checkboxStub);
+        frame.add(choiceStub);
+        frame.add(lwComponentStub);
+        frame.add(containerStub);
+        frame.add(labelStub);
+        frame.add(listStub);
+        frame.add(panelStub);
+        frame.add(scrollbarStub);
+        frame.add(scrollPaneStub);
+        frame.add(textAreaStub);
+        frame.add(textFieldStub);
+        frame.setSize(new Dimension(500, 500));
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+        sleep();
+
+        //Check results.
+        validation();
+
+        //Reset all flags to 'false'.
+        initPaintedFlags();
+
+        //Tested method.
+        frame.paintAll(g);
+        sleep();
+
+        //Check results.
+        validation();
+        cleanup();
+    }
+
+    private static void initPaintedFlags() {
+        lwPainted = false;
+        buttonPainted = false;
+        canvasPainted = false;
+        checkboxPainted = false;
+        choicePainted = false;
+        containerPainted = false;
+        framePainted = false;
+        labelPainted = false;
+        listPainted = false;
+        panelPainted = false;
+        scrollbarPainted = false;
+        scrollPanePainted = false;
+        textAreaPainted = false;
+        textFieldPainted = false;
+    }
+
+    private static void validation() {
+        if (!buttonPainted) {
+            fail("Paint is not called a Button "
+                 + "when paintAll() invoked on a parent");
+        }
+        if (!canvasPainted) {
+            fail("Paint is not called a Canvas "
+                 + "when paintAll() invoked on a parent");
+        }
+        if (!checkboxPainted) {
+            fail("Paint is not called a Checkbox "
+                 + "when paintAll() invoked on a parent");
+        }
+        if (!choicePainted) {
+            fail("Paint is not called a Choice "
+                 + "when paintAll() invoked on a parent");
+        }
+        if (!lwPainted) {
+            fail("Paint is not called on a lightweight"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!containerPainted) {
+            fail("Paint is not called on a Container"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!labelPainted) {
+            fail("Paint is not called on a Label"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!listPainted) {
+            fail("Paint is not called on a List"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!panelPainted) {
+            fail("Paint is not called on a Panel"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!scrollbarPainted) {
+            fail("Paint is not called on a Scrollbar"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!scrollPanePainted) {
+            fail("Paint is not called on a ScrollPane"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!textAreaPainted) {
+            fail("Paint is not called on a TextArea"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!textFieldPainted) {
+            fail("Paint is not called on a TextField"
+                 + " subcomponent when paintAll() invoked on a parent");
+        }
+        if (!framePainted) {
+            fail("Paint is not called on a Frame when paintAll()");
+        }
+    }
+
+    private static void sleep() {
+        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        try {
+            Thread.sleep(500L);
+        } catch (InterruptedException ignored) {
+        }
+    }
+
+    private static void fail(final String message) {
+        cleanup();
+        throw new RuntimeException(message);
+    }
+
+    private static void cleanup() {
+        frame.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/text/Bidi/Bug7042148.java	Wed Jul 27 22:42:19 2011 -0700
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7042148
+ * @summary verify that Bidi.baseIsLeftToRight() returns the correct value even if an incorrect position is set in the given AttributedCharacterIterator.
+ */
+import java.awt.font.*;
+import java.text.*;
+import java.util.*;
+
+public class Bug7042148 {
+
+    private static boolean err = false;
+
+    public static void main(String[] args) {
+        testDirection();
+
+        if (err) {
+            throw new RuntimeException("Failed");
+        } else {
+            System.out.println("Passed.");
+        }
+    }
+
+    private static void testDirection() {
+        Map attrLTR = new HashMap();
+        attrLTR.put(TextAttribute.RUN_DIRECTION,
+                    TextAttribute.RUN_DIRECTION_LTR);
+        Map attrRTL = new HashMap();
+        attrRTL.put(TextAttribute.RUN_DIRECTION,
+                    TextAttribute.RUN_DIRECTION_RTL);
+
+        String str1 = "A\u05e0";
+        String str2 = "\u05e0B";
+
+        test(str1, attrLTR, Bidi.DIRECTION_LEFT_TO_RIGHT);
+        test(str1, attrRTL, Bidi.DIRECTION_RIGHT_TO_LEFT);
+        test(str2, attrLTR, Bidi.DIRECTION_LEFT_TO_RIGHT);
+        test(str2, attrRTL, Bidi.DIRECTION_RIGHT_TO_LEFT);
+    }
+
+    private static void test(String text, Map attr, int dirFlag) {
+        boolean expected = (dirFlag == Bidi.DIRECTION_LEFT_TO_RIGHT);
+
+        Bidi bidi = new Bidi(text, dirFlag);
+        boolean got = bidi.baseIsLeftToRight();
+        if (got != expected) {
+            err = true;
+            System.err.println("wrong Bidi(String, int).baseIsLeftToRight() value: " +
+                               "\n\ttext=" + text +
+                               "\n\tExpected=" + expected +
+                               "\n\tGot=" + got);
+        }
+
+        AttributedString as = new AttributedString(text, attr);
+        AttributedCharacterIterator itr = as.getIterator();
+        itr.last();
+        itr.next();
+        bidi = new Bidi(itr);
+        got = bidi.baseIsLeftToRight();
+        if (got != expected) {
+            err = true;
+            System.err.println("Wrong Bidi(AttributedCharacterIterator).baseIsLeftToRight() value: " +
+                               "\n\ttext=" + text +
+                               "\n\tExpected=" + expected +
+                               "\n\tGot=" + got);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/text/Bidi/Bug7051769.java	Wed Jul 27 22:42:19 2011 -0700
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7051769
+ * @summary verify that Bidi.toString() returns the corect result.
+ */
+import java.awt.font.*;
+import java.text.*;
+import java.util.*;
+
+public class Bug7051769 {
+
+    private static boolean err = false;
+
+    public static void main(String[] args) {
+        testNumericShaping();
+
+        if (err) {
+            throw new RuntimeException("Failed");
+        } else {
+            System.out.println("Passed.");
+        }
+    }
+
+    private static void testNumericShaping() {
+        Map attrNS = new HashMap();
+        attrNS.put(TextAttribute.NUMERIC_SHAPING,
+                   NumericShaper.getContextualShaper(NumericShaper.ARABIC));
+        attrNS.put(TextAttribute.RUN_DIRECTION,
+                   TextAttribute.RUN_DIRECTION_RTL);
+
+        String text = "\u0623\u0643\u062a\u0648\u0628\u0631 10";
+        String expected = "sun.text.bidi.BidiBase[dir: 2 baselevel: 1 length: 9 runs: [1 1 1 1 1 1 1 2 2] text: [0x623 0x643 0x62a 0x648 0x628 0x631 0x20 0x661 0x660]]";
+
+        AttributedString as = new AttributedString(text, attrNS);
+        AttributedCharacterIterator itr = as.getIterator();
+        itr.last();
+        itr.next();
+        Bidi bidi = new Bidi(itr);
+        String got = bidi.toString();
+
+        if (!got.equals(expected)) {
+            err = true;
+            System.err.println("Wrong toString() output: " +
+                               "\n\tExpected=" + expected +
+                               "\n\tGot=" + got);
+        }
+    }
+
+}