changeset 14326:9d1077f29022

8132791: No access to SynthContext.getContext() Reviewed-by: serb, ssadetsky
author alexsch
date Fri, 15 Apr 2016 19:15:12 +0400
parents 735a130dc8db
children 902e7cbe0acd
files src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
diffstat 39 files changed, 11 insertions(+), 242 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java	Fri Apr 15 19:15:12 2016 +0400
@@ -139,7 +139,6 @@
                 }
             }
 
-            context.dispose();
             return dim;
         }
     }
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java	Fri Apr 15 19:15:12 2016 +0400
@@ -61,7 +61,6 @@
             return;
         }
         ui.paintBorder(context, g, x, y, width, height);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -105,7 +105,6 @@
             }
 
         }
-        context.dispose();
     }
 
     /**
@@ -125,7 +124,6 @@
         SynthContext context = getContext(b, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -226,7 +224,6 @@
         else {
             baseline = textRect.y + fm.getAscent();
         }
-        context.dispose();
         return baseline;
     }
 
@@ -253,7 +250,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -270,7 +266,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -321,7 +316,6 @@
     protected Icon getDefaultIcon(AbstractButton b) {
         SynthContext context = getContext(b);
         Icon icon = context.getStyle().getIcon(context, getPropertyPrefix() + "icon");
-        context.dispose();
         return icon;
     }
 
@@ -473,7 +467,6 @@
                b.getVerticalTextPosition(), b.getIconTextGap(),
                b.getDisplayedMnemonicIndex());
 
-        ss.dispose();
         return size;
     }
 
@@ -494,7 +487,6 @@
                b.getVerticalTextPosition(), b.getIconTextGap(),
                b.getDisplayedMnemonicIndex());
 
-        ss.dispose();
         return size;
     }
 
@@ -516,7 +508,6 @@
                b.getVerticalTextPosition(), b.getIconTextGap(),
                b.getDisplayedMnemonicIndex());
 
-        ss.dispose();
         return size;
     }
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -65,7 +65,6 @@
         SynthContext context = getContext(chooser, ENABLED);
         AbstractColorChooserPanel[] panels = (AbstractColorChooserPanel[])
                      context.getStyle().get(context, "ColorChooser.panels");
-        context.dispose();
 
         if (panels == null) {
             panels = ColorChooserComponentFactory.getDefaultChooserPanels();
@@ -85,7 +84,6 @@
     private void updateStyle(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -96,7 +94,6 @@
         SynthContext context = getContext(chooser, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         super.uninstallDefaults();
     }
@@ -155,7 +152,6 @@
         context.getPainter().paintColorChooserBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -172,7 +168,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -144,7 +144,6 @@
             forceOpaque = style.getBoolean(context,
                     "ComboBox.forceOpaque", false);
         }
-        context.dispose();
 
         if(listBox != null) {
             SynthLookAndFeel.updateStyles(listBox);
@@ -182,7 +181,6 @@
         SynthContext context = getContext(comboBox, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -323,7 +321,6 @@
         context.getPainter().paintComboBoxBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -340,7 +337,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java	Fri Apr 15 19:15:12 2016 +0400
@@ -24,8 +24,6 @@
  */
 package javax.swing.plaf.synth;
 
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
 import javax.swing.JComponent;
 
 /**
@@ -40,7 +38,6 @@
  * @author Scott Violet
  */
 public class SynthContext {
-    private static final Queue<SynthContext> queue = new ConcurrentLinkedQueue<>();
 
     private JComponent component;
     private Region region;
@@ -54,19 +51,15 @@
     static SynthContext getContext(JComponent component,
                                    Region region, SynthStyle style,
                                    int state) {
-        SynthContext context = queue.poll();
-        if (context == null) {
-            context = new SynthContext();
-        }
-        context.reset(component, region, style, state);
+        SynthContext context = new SynthContext();
+        context.component = component;
+        context.region = region;
+        context.style = style;
+        context.state = state;
         return context;
     }
 
-    static void releaseContext(SynthContext context) {
-        queue.offer(context);
-    }
-
-    SynthContext() {
+    private SynthContext() {
     }
 
     /**
@@ -86,7 +79,11 @@
             throw new NullPointerException(
                 "You must supply a non-null component, region and style");
         }
-        reset(component, region, style, state);
+
+        this.component = component;
+        this.region = region;
+        this.style = style;
+        this.state = state;
     }
 
 
@@ -147,23 +144,6 @@
     }
 
     /**
-     * Resets the state of the Context.
-     */
-    void reset(JComponent component, Region region, SynthStyle style,
-               int state) {
-        this.component = component;
-        this.region = region;
-        this.style = style;
-        this.state = state;
-    }
-
-    void dispose() {
-        this.component = null;
-        this.style = null;
-        releaseContext(this);
-    }
-
-    /**
      * Convenience method to get the Painter from the current SynthStyle.
      * This will NEVER return null.
      */
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java	Fri Apr 15 19:15:12 2016 +0400
@@ -41,7 +41,6 @@
         }
         SynthContext context = ((SynthUI)ui).getContext(c);
         Object value = context.getStyle().get(context, key);
-        context.dispose();
         return value;
     }
 }
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -121,7 +121,6 @@
     private void updateStyle(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -131,7 +130,6 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(desktopIcon, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -171,7 +169,6 @@
         context.getPainter().paintDesktopIconBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -188,7 +185,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -119,7 +119,6 @@
             uninstallKeyboardActions();
             installKeyboardActions();
         }
-        context.dispose();
     }
 
     /**
@@ -143,7 +142,6 @@
         SynthContext context = getContext(desktop, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         if (taskBar != null) {
@@ -460,7 +458,6 @@
         context.getPainter().paintDesktopPaneBackground(context, g, 0, 0,
                                                   c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -477,7 +474,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -83,7 +83,6 @@
         c.putClientProperty("caretAspectRatio", null);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         Object clientProperty =
@@ -127,7 +126,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -165,7 +163,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Fri Apr 15 19:15:12 2016 +0400
@@ -138,7 +138,6 @@
                 }
             }
         }
-        context.dispose();
     }
 
     protected void installDefaults() {
@@ -149,7 +148,6 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(this, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
         if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
@@ -235,7 +233,6 @@
         context.getPainter().paintInternalFrameTitlePaneBackground(context,
                           g, 0, 0, getWidth(), getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     protected void paint(SynthContext context, Graphics g) {
@@ -321,7 +318,6 @@
         SynthContext context = getContext(this);
         LayoutManager lm =
             (LayoutManager)style.get(context, "InternalFrameTitlePane.titlePaneLayout");
-        context.dispose();
         return (lm != null) ? lm : new SynthTitlePaneLayout();
     }
 
@@ -362,7 +358,6 @@
                              Image.SCALE_SMOOTH));
             }
         }
-        context.dispose();
         menuButton.setIcon(frameIcon);
     }
 
@@ -433,7 +428,6 @@
             Insets insets = getInsets();
             height += insets.top + insets.bottom;
             width += insets.left + insets.right;
-            context.dispose();
             return new Dimension(width, height);
         }
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -118,7 +118,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -128,7 +127,6 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(frame, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         if(frame.getLayout() == internalFrameLayout) {
             frame.setLayout(null);
@@ -216,7 +214,6 @@
         context.getPainter().paintInternalFrameBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -233,7 +230,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -67,7 +67,6 @@
     void updateStyle(JLabel c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -78,7 +77,6 @@
         SynthContext context = getContext(c, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -150,7 +148,6 @@
         else {
             baseline = textRect.y + fm.getAscent();
         }
-        context.dispose();
         return baseline;
     }
 
@@ -174,7 +171,6 @@
         context.getPainter().paintLabelBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -191,7 +187,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -242,7 +237,6 @@
                label.getVerticalTextPosition(), label.getIconTextGap(),
                label.getDisplayedMnemonicIndex());
 
-        context.dispose();
         return size;
     }
 
@@ -263,7 +257,6 @@
                label.getVerticalTextPosition(), label.getIconTextGap(),
                label.getDisplayedMnemonicIndex());
 
-        context.dispose();
         return size;
     }
 
@@ -284,7 +277,6 @@
                label.getVerticalTextPosition(), label.getIconTextGap(),
                label.getDisplayedMnemonicIndex());
 
-        context.dispose();
         return size;
     }
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -75,7 +75,6 @@
         SynthLookAndFeel.update(context, g);
         context.getPainter().paintListBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
-        context.dispose();
         paint(g, c);
     }
 
@@ -162,7 +161,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -175,7 +173,6 @@
         SynthContext context = getContext(list, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java	Fri Apr 15 19:15:12 2016 +0400
@@ -976,7 +976,6 @@
                 if (currBG != null && !currBG.equals(lastBG)) {
                     comp.repaint();
                 }
-                context.dispose();
             }
         }
     }
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -83,7 +83,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -94,7 +93,6 @@
         SynthContext context = getContext(menuBar, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -143,7 +141,6 @@
         context.getPainter().paintMenuBarBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -160,7 +157,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -124,13 +124,11 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
                                              ENABLED);
 
         accStyle = SynthLookAndFeel.updateStyle(accContext, this);
-        accContext.dispose();
     }
 
     /**
@@ -140,13 +138,11 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(menuItem, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         SynthContext accContext = getContext(menuItem,
                                      Region.MENU_ITEM_ACCELERATOR, ENABLED);
         accStyle.uninstallDefaults(accContext);
-        accContext.dispose();
         accStyle = null;
 
         super.uninstallDefaults();
@@ -218,8 +214,6 @@
                 defaultTextIconGap, acceleratorDelimiter,
                 MenuItemLayoutHelper.useCheckAndArrow(menuItem),
                 getPropertyPrefix());
-        context.dispose();
-        accContext.dispose();
         return value;
     }
 
@@ -243,7 +237,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -260,7 +253,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -280,7 +272,6 @@
         Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
         SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
               acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
-        accContext.dispose();
     }
 
     void paintBackground(SynthContext context, Graphics g, JComponent c) {
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -110,13 +110,11 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
                                              ENABLED);
 
         accStyle = SynthLookAndFeel.updateStyle(accContext, this);
-        accContext.dispose();
     }
 
     /**
@@ -140,13 +138,11 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(menuItem, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         SynthContext accContext = getContext(menuItem,
                                      Region.MENU_ITEM_ACCELERATOR, ENABLED);
         accStyle.uninstallDefaults(accContext);
-        accContext.dispose();
         accStyle = null;
 
         super.uninstallDefaults();
@@ -218,8 +214,6 @@
                 defaultTextIconGap, acceleratorDelimiter,
                 MenuItemLayoutHelper.useCheckAndArrow(menuItem),
                 getPropertyPrefix());
-        context.dispose();
-        accContext.dispose();
         return value;
     }
 
@@ -243,7 +237,6 @@
         context.getPainter().paintMenuBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -260,7 +253,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -279,7 +271,6 @@
         Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
         SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
               acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
-        accContext.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -88,7 +88,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -99,7 +98,6 @@
         SynthContext context = getContext(optionPane, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -125,7 +123,6 @@
             SynthContext context = getContext(optionPane, ENABLED);
             optionPane.add(Box.createVerticalStrut(context.getStyle().
                        getInt(context, "OptionPane.separatorPadding", 6)));
-            context.dispose();
         }
         optionPane.add(createButtonArea());
         optionPane.applyComponentOrientation(optionPane.getComponentOrientation());
@@ -167,7 +164,6 @@
         context.getPainter().paintOptionPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -184,7 +180,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -259,7 +254,6 @@
         SynthContext context = getContext(optionPane, ENABLED);
         cons.anchor = context.getStyle().getInt(context,
                       "OptionPane.messageAnchor", GridBagConstraints.CENTER);
-        context.dispose();
 
         cons.insets = new Insets(0,0,3,0);
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -108,14 +108,12 @@
         SynthContext context = getContext(p, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
     private void updateStyle(JPanel c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -154,7 +152,6 @@
         context.getPainter().paintPanelBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -171,7 +168,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -77,7 +77,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -97,7 +96,6 @@
         SynthContext context = getContext(popupMenu, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         if (popupMenu.getLayout() instanceof UIResource) {
@@ -150,7 +148,6 @@
         context.getPainter().paintPopupMenuBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -167,7 +164,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -118,7 +118,6 @@
         }
         minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
         glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
-        context.dispose();
     }
 
     /**
@@ -129,7 +128,6 @@
         SynthContext context = getContext(progressBar, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -160,7 +158,6 @@
             SynthContext context = getContext(c);
             Font font = context.getStyle().getFont(context);
             FontMetrics metrics = progressBar.getFontMetrics(font);
-            context.dispose();
             return (height - metrics.getAscent() - metrics.getDescent()) / 2 +
                     metrics.getAscent();
         }
@@ -216,7 +213,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           progressBar.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -233,7 +229,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -67,7 +67,6 @@
         SynthContext context = getContext(root, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -97,7 +96,6 @@
                 installKeyboardActions((JRootPane)c);
             }
         }
-        context.dispose();
     }
 
     /**
@@ -120,7 +118,6 @@
         context.getPainter().paintRootPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -137,7 +134,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -129,15 +129,12 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         context = getContext(c, Region.SCROLL_BAR_TRACK, ENABLED);
         trackStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, Region.SCROLL_BAR_THUMB, ENABLED);
         thumbStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -165,17 +162,14 @@
     protected void uninstallDefaults(){
         SynthContext context = getContext(scrollbar, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(scrollbar, Region.SCROLL_BAR_TRACK, ENABLED);
         trackStyle.uninstallDefaults(context);
-        context.dispose();
         trackStyle = null;
 
         context = getContext(scrollbar, Region.SCROLL_BAR_THUMB, ENABLED);
         thumbStyle.uninstallDefaults(context);
-        context.dispose();
         thumbStyle = null;
 
         super.uninstallDefaults();
@@ -222,7 +216,6 @@
         SynthContext context = getContext(scrollbar);
         boolean value = style.getBoolean(context,
                       "ScrollBar.allowsAbsolutePositioning", false);
-        context.dispose();
         return value;
     }
 
@@ -247,7 +240,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           scrollbar.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -264,7 +256,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -278,11 +269,9 @@
         SynthContext subcontext = getContext(scrollbar,
                                              Region.SCROLL_BAR_TRACK);
         paintTrack(subcontext, g, getTrackBounds());
-        subcontext.dispose();
 
         subcontext = getContext(scrollbar, Region.SCROLL_BAR_THUMB);
         paintThumb(subcontext, g, getThumbBounds());
-        subcontext.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -83,7 +83,6 @@
         context.getPainter().paintScrollPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -100,7 +99,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -150,7 +148,6 @@
                 installKeyboardActions(c);
             }
         }
-        context.dispose();
     }
 
     /**
@@ -178,7 +175,6 @@
         SynthContext context = getContext(c, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
 
         if (scrollpane.getViewportBorder() instanceof UIResource) {
             scrollpane.setViewportBorder(null);
@@ -254,7 +250,6 @@
             }
             context.getPainter().paintViewportBorder(context, g, x, y, width,
                                                      height);
-            context.dispose();
         }
 
         @Override
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -106,7 +106,6 @@
             }
         }
 
-        context.dispose();
     }
 
     /**
@@ -120,7 +119,6 @@
         SynthContext context = getContext(c, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -168,7 +166,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           separator.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -185,7 +182,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -231,7 +227,6 @@
             size = new Dimension(insets.left + insets.right,
                                  insets.top + insets.bottom + thickness);
         }
-        context.dispose();
         return size;
     }
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -116,17 +116,14 @@
     protected void uninstallDefaults(JSlider slider) {
         SynthContext context = getContext(slider, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(slider, Region.SLIDER_TRACK, ENABLED);
         sliderTrackStyle.uninstallDefaults(context);
-        context.dispose();
         sliderTrackStyle = null;
 
         context = getContext(slider, Region.SLIDER_THUMB, ENABLED);
         sliderThumbStyle.uninstallDefaults(context);
-        context.dispose();
         sliderThumbStyle = null;
     }
 
@@ -190,17 +187,14 @@
                 installKeyboardActions(c);
             }
         }
-        context.dispose();
 
         context = getContext(c, Region.SLIDER_TRACK, ENABLED);
         sliderTrackStyle =
             SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, Region.SLIDER_THUMB, ENABLED);
         sliderThumbStyle =
             SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -252,14 +246,12 @@
             SynthContext trackContext = getContext(slider,
                                                    Region.SLIDER_TRACK);
             style.getInsets(trackContext, trackInsets);
-            trackContext.dispose();
             if (slider.getOrientation() == JSlider.HORIZONTAL) {
                 int valueHeight = 0;
                 if (paintValue) {
                     SynthContext context = getContext(slider);
                     valueHeight = context.getStyle().getGraphicsUtils(context).
                             getMaximumCharHeight(context);
-                    context.dispose();
                 }
                 int tickHeight = 0;
                 if (slider.getPaintTicks()) {
@@ -287,7 +279,6 @@
                         SynthContext context = getContext(slider);
                         valueHeight = context.getStyle().getGraphicsUtils(
                                 context).getMaximumCharHeight(context);
-                        context.dispose();
                     }
                     int contentHeight = height - insetCache.top -
                             insetCache.bottom;
@@ -359,7 +350,6 @@
         Insets trackInsets = new Insets(0, 0, 0, 0);
         SynthContext trackContext = getContext(slider, Region.SLIDER_TRACK);
         style.getInsets(trackContext, trackInsets);
-        trackContext.dispose();
 
         if (slider.getOrientation() == JSlider.HORIZONTAL) {
             // Calculate the height of all the subcomponents so we can center
@@ -509,7 +499,6 @@
                 trackRect.x = startX + tickRect.width + trackInsets.left;
             }
         }
-        context.dispose();
         lastSize = slider.getSize();
     }
 
@@ -715,7 +704,6 @@
             insetCache = newInsets;
             calculateGeometry();
         }
-        context.dispose();
     }
 
     /**
@@ -774,7 +762,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           slider.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -790,7 +777,6 @@
     public void paint(Graphics g, JComponent c) {
         SynthContext context = getContext(c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -835,13 +821,11 @@
         if (slider.getPaintTrack() && clip.intersects(trackRect)) {
             SynthContext subcontext = getContext(slider, Region.SLIDER_TRACK);
             paintTrack(subcontext, g, trackRect);
-            subcontext.dispose();
         }
 
         if (clip.intersects(thumbRect)) {
             SynthContext subcontext = getContext(slider, Region.SLIDER_THUMB);
             paintThumb(subcontext, g, thumbRect);
-            subcontext.dispose();
         }
 
         if (slider.getPaintTicks() && clip.intersects(tickRect)) {
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -131,7 +131,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
 
@@ -151,7 +150,6 @@
         SynthContext context = getContext(spinner, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -301,7 +299,6 @@
         context.getPainter().paintSpinnerBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
 
@@ -319,7 +316,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java	Fri Apr 15 19:15:12 2016 +0400
@@ -81,7 +81,6 @@
 
         context.getPainter().paintSplitPaneDividerForeground(context, g, 0, 0,
                 getWidth(), getHeight(), splitPane.getOrientation());
-        context.dispose();
 
         // super.paint(g2);
         for (int counter = 0; counter < getComponentCount(); counter++) {
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -121,7 +121,6 @@
                                           ENABLED);
         SynthStyle oldDividerStyle = dividerStyle;
         dividerStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(splitPane, ENABLED);
         SynthStyle oldStyle = style;
@@ -160,7 +159,6 @@
             divider.setBasicSplitPaneUI(this);
             splitPane.add(divider, JSplitPane.DIVIDER);
         }
-        context.dispose();
     }
 
     /**
@@ -180,12 +178,10 @@
         SynthContext context = getContext(splitPane, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED);
         dividerStyle.uninstallDefaults(context);
-        context.dispose();
         dividerStyle = null;
 
         super.uninstallDefaults();
@@ -287,7 +283,6 @@
         context.getPainter().paintSplitPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -304,7 +299,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -338,7 +332,6 @@
         context.getPainter().paintSplitPaneDragDivider(context, g, x, y, w, h,
                                            splitPane.getOrientation());
         g.setClip(oldClip);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -154,27 +154,17 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
-        if (tabContext != null) {
-            tabContext.dispose();
-        }
         tabContext = getContext(c, Region.TABBED_PANE_TAB, ENABLED);
         this.tabStyle = SynthLookAndFeel.updateStyle(tabContext, this);
         tabInsets = tabStyle.getInsets(tabContext, null);
 
 
-        if (tabAreaContext != null) {
-            tabAreaContext.dispose();
-        }
         tabAreaContext = getContext(c, Region.TABBED_PANE_TAB_AREA, ENABLED);
         this.tabAreaStyle = SynthLookAndFeel.updateStyle(tabAreaContext, this);
         tabAreaInsets = tabAreaStyle.getInsets(tabAreaContext, null);
 
 
-        if (tabContentContext != null) {
-            tabContentContext.dispose();
-        }
         tabContentContext = getContext(c, Region.TABBED_PANE_CONTENT, ENABLED);
         this.tabContentStyle = SynthLookAndFeel.updateStyle(tabContentContext,
                                                             this);
@@ -207,21 +197,17 @@
     protected void uninstallDefaults() {
         SynthContext context = getContext(tabPane, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         tabStyle.uninstallDefaults(tabContext);
-        tabContext.dispose();
         tabContext = null;
         tabStyle = null;
 
         tabAreaStyle.uninstallDefaults(tabAreaContext);
-        tabAreaContext.dispose();
         tabAreaContext = null;
         tabAreaStyle = null;
 
         tabContentStyle.uninstallDefaults(tabContentContext);
-        tabContentContext.dispose();
         tabContentContext = null;
         tabContentStyle = null;
     }
@@ -374,7 +360,6 @@
         context.getPainter().paintTabbedPaneBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -424,7 +409,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -85,7 +85,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -109,7 +108,6 @@
         SynthContext context = getContext(header, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -142,7 +140,6 @@
         context.getPainter().paintTableHeaderBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -159,7 +156,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -189,7 +189,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -220,7 +219,6 @@
         }
         SynthContext context = getContext(table, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -273,7 +271,6 @@
         context.getPainter().paintTableBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -299,7 +296,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -88,7 +88,6 @@
         getComponent().removeFocusListener(handler);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         super.uninstallDefaults();
     }
@@ -107,7 +106,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -142,7 +140,6 @@
         context.getPainter().paintTextAreaBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -79,7 +79,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     static void updateStyle(JTextComponent comp, SynthContext context,
@@ -179,7 +178,6 @@
         SynthLookAndFeel.update(context, g);
         paintBackground(context, g, c);
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -262,7 +260,6 @@
         getComponent().removeFocusListener(handler);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
         super.uninstallDefaults();
     }
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -98,11 +98,9 @@
         SynthContext context = getContext(
                 c, Region.TOOL_BAR_CONTENT, null, ENABLED);
         contentStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, Region.TOOL_BAR_DRAG_WINDOW, null, ENABLED);
         dragWindowStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
 
         context = getContext(c, ENABLED);
         SynthStyle oldStyle = style;
@@ -116,7 +114,6 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
     }
 
     /**
@@ -127,7 +124,6 @@
         SynthContext context = getContext(toolBar, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         handleIcon = null;
@@ -135,13 +131,11 @@
         context = getContext(toolBar, Region.TOOL_BAR_CONTENT,
                              contentStyle, ENABLED);
         contentStyle.uninstallDefaults(context);
-        context.dispose();
         contentStyle = null;
 
         context = getContext(toolBar, Region.TOOL_BAR_DRAG_WINDOW,
                              dragWindowStyle, ENABLED);
         dragWindowStyle.uninstallDefaults(context);
-        context.dispose();
         dragWindowStyle = null;
 
         toolBar.setLayout(null);
@@ -215,7 +209,6 @@
                           g, 0, 0, c.getWidth(), c.getHeight(),
                           toolBar.getOrientation());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -232,7 +225,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -289,7 +281,6 @@
         SynthContext subcontext = getContext(
                 toolBar, Region.TOOL_BAR_CONTENT, contentStyle);
         paintContent(subcontext, g, contentRect);
-        subcontext.dispose();
     }
 
     /**
@@ -326,7 +317,6 @@
                                                            dragWindow.getOrientation());
         context.getPainter().paintToolBarDragWindowBorder(context, g, 0, 0, w, h,
                                                           dragWindow.getOrientation());
-        context.dispose();
     }
 
     //
@@ -383,7 +373,6 @@
             dim.width += insets.left + insets.right;
             dim.height += insets.top + insets.bottom;
 
-            context.dispose();
             return dim;
         }
 
@@ -421,7 +410,6 @@
             dim.width += insets.left + insets.right;
             dim.height += insets.top + insets.bottom;
 
-            context.dispose();
             return dim;
         }
 
@@ -543,7 +531,6 @@
                     }
                 }
             }
-            context.dispose();
         }
 
         private boolean isGlue(Component c) {
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -68,7 +68,6 @@
     private void updateStyle(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -78,7 +77,6 @@
     protected void uninstallDefaults(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -139,7 +137,6 @@
         context.getPainter().paintToolTipBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -165,7 +162,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -218,7 +214,6 @@
                 prefSize.height += fm.getHeight();
             }
         }
-        context.dispose();
         return prefSize;
     }
 
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -147,11 +147,9 @@
                 installKeyboardActions();
             }
         }
-        context.dispose();
 
         context = getContext(tree, Region.TREE_CELL, ENABLED);
         cellStyle = SynthLookAndFeel.updateStyle(context, this);
-        context.dispose();
     }
 
     /**
@@ -223,12 +221,10 @@
         SynthContext context = getContext(tree, ENABLED);
 
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
 
         context = getContext(tree, Region.TREE_CELL, ENABLED);
         cellStyle.uninstallDefaults(context);
-        context.dispose();
         cellStyle = null;
 
 
@@ -266,7 +262,6 @@
         context.getPainter().paintTreeBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -292,7 +287,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -425,7 +419,6 @@
                 row++;
             }
         }
-        cellContext.dispose();
 
         paintDropLine(g);
 
@@ -743,7 +736,6 @@
                     context.getPainter().paintTreeCellFocus(context, g,
                             0, 0, getWidth() - imageOffset, getHeight());
                 }
-                context.dispose();
             }
             SynthLookAndFeel.resetSelectedUI();
         }
@@ -785,7 +777,6 @@
             if (context == null) {
                 context = getContext(tree);
                 SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
-                context.dispose();
             }
             else {
                 SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
@@ -797,7 +788,6 @@
             if (context == null) {
                 context = getContext(tree);
                 width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
-                context.dispose();
             }
             else {
                 width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
@@ -810,7 +800,6 @@
             if (context == null) {
                 context = getContext(tree);
                 height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
-                context.dispose();
             }
             else {
                 height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java	Fri Apr 15 15:50:45 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java	Fri Apr 15 19:15:12 2016 +0400
@@ -99,7 +99,6 @@
             newStyle.installDefaults(context);
         }
         this.style = newStyle;
-        context.dispose();
     }
 
     /**
@@ -128,7 +127,6 @@
     protected void uninstallDefaults(JComponent c) {
         SynthContext context = getContext(c, ENABLED);
         style.uninstallDefaults(context);
-        context.dispose();
         style = null;
     }
 
@@ -168,7 +166,6 @@
         context.getPainter().paintViewportBackground(context,
                           g, 0, 0, c.getWidth(), c.getHeight());
         paint(context, g);
-        context.dispose();
     }
 
     /**
@@ -202,7 +199,6 @@
         SynthContext context = getContext(c);
 
         paint(context, g);
-        context.dispose();
     }
 
     /**