diff options
author | asaha <none@none> | 2014-06-26 07:54:37 -0700 |
---|---|---|
committer | asaha <none@none> | 2014-06-26 07:54:37 -0700 |
commit | 3ddb7dde79bd071799cb2f737420e58ef099f395 (patch) | |
tree | 1a6eaf9f14cf21c90c6c37b92b2d967902070878 /src/share/classes/javax | |
parent | 3129d799b401b8f9197dd38119ef830fe3983b2f (diff) | |
parent | 8f9fe9ab3bfb48e477a7fabd91f95e002184e92a (diff) |
Merge
Diffstat (limited to 'src/share/classes/javax')
-rw-r--r-- | src/share/classes/javax/swing/DefaultDesktopManager.java | 10 | ||||
-rw-r--r-- | src/share/classes/javax/swing/JComboBox.java | 16 | ||||
-rw-r--r-- | src/share/classes/javax/swing/JComponent.java | 9 | ||||
-rw-r--r-- | src/share/classes/javax/swing/JDialog.java | 1 | ||||
-rw-r--r-- | src/share/classes/javax/swing/JViewport.java | 22 | ||||
-rw-r--r-- | src/share/classes/javax/swing/PopupFactory.java | 26 | ||||
-rw-r--r-- | src/share/classes/javax/swing/RepaintManager.java | 42 | ||||
-rw-r--r-- | src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java | 5 |
8 files changed, 92 insertions, 39 deletions
diff --git a/src/share/classes/javax/swing/DefaultDesktopManager.java b/src/share/classes/javax/swing/DefaultDesktopManager.java index 806ec3421..e44c9d939 100644 --- a/src/share/classes/javax/swing/DefaultDesktopManager.java +++ b/src/share/classes/javax/swing/DefaultDesktopManager.java @@ -677,6 +677,11 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab f.setBounds(currentBounds); + if (!floaterCollision) { + Rectangle r = currentBounds; + currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height); + } + if(floaterCollision) { // since we couldn't blit we just redraw as fast as possible // the isDragging mucking is to avoid activating emergency @@ -706,6 +711,8 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab // Fix the damage for (int i = 0; i < dirtyRects.length; i++) { parent.paintImmediately(dirtyRects[i]); + Rectangle r = dirtyRects[i]; + currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height); } // new areas of blit were exposed @@ -716,9 +723,10 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab dirtyRects[i].x += newX - previousBounds.x; dirtyRects[i].y += newY - previousBounds.y; ((JInternalFrame)f).isDragging = false; - parent.paintImmediately(dirtyRects[i]); ((JInternalFrame)f).isDragging = true; + Rectangle r = dirtyRects[i]; + currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height); } } diff --git a/src/share/classes/javax/swing/JComboBox.java b/src/share/classes/javax/swing/JComboBox.java index a5af75305..1e0be3c8f 100644 --- a/src/share/classes/javax/swing/JComboBox.java +++ b/src/share/classes/javax/swing/JComboBox.java @@ -1307,13 +1307,15 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible { * do not call or override. */ public void actionPerformed(ActionEvent e) { - Object newItem = getEditor().getItem(); - setPopupVisible(false); - getModel().setSelectedItem(newItem); - String oldCommand = getActionCommand(); - setActionCommand("comboBoxEdited"); - fireActionEvent(); - setActionCommand(oldCommand); + ComboBoxEditor editor = getEditor(); + if ((editor != null) && (e != null) && (editor == e.getSource())) { + setPopupVisible(false); + getModel().setSelectedItem(editor.getItem()); + String oldCommand = getActionCommand(); + setActionCommand("comboBoxEdited"); + fireActionEvent(); + setActionCommand(oldCommand); + } } /** diff --git a/src/share/classes/javax/swing/JComponent.java b/src/share/classes/javax/swing/JComponent.java index 8a1bc1826..803c13fd0 100644 --- a/src/share/classes/javax/swing/JComponent.java +++ b/src/share/classes/javax/swing/JComponent.java @@ -3676,8 +3676,8 @@ public abstract class JComponent extends Container implements Serializable, private volatile transient int propertyListenersCount = 0; /** - * This field duplicates the one in java.awt.Component.AccessibleAWTComponent, - * so it has been deprecated. + * This field duplicates the function of the accessibleAWTFocusHandler field + * in java.awt.Component.AccessibleAWTComponent, so it has been deprecated. */ @Deprecated protected FocusListener accessibleFocusHandler = null; @@ -3735,14 +3735,10 @@ public abstract class JComponent extends Container implements Serializable, * @param listener the PropertyChangeListener to be added */ public void addPropertyChangeListener(PropertyChangeListener listener) { - if (accessibleFocusHandler == null) { - accessibleFocusHandler = new AccessibleFocusHandler(); - } if (accessibleContainerHandler == null) { accessibleContainerHandler = new AccessibleContainerHandler(); } if (propertyListenersCount++ == 0) { - JComponent.this.addFocusListener(accessibleFocusHandler); JComponent.this.addContainerListener(accessibleContainerHandler); } super.addPropertyChangeListener(listener); @@ -3757,7 +3753,6 @@ public abstract class JComponent extends Container implements Serializable, */ public void removePropertyChangeListener(PropertyChangeListener listener) { if (--propertyListenersCount == 0) { - JComponent.this.removeFocusListener(accessibleFocusHandler); JComponent.this.removeContainerListener(accessibleContainerHandler); } super.removePropertyChangeListener(listener); diff --git a/src/share/classes/javax/swing/JDialog.java b/src/share/classes/javax/swing/JDialog.java index 4ae5e434c..51228851f 100644 --- a/src/share/classes/javax/swing/JDialog.java +++ b/src/share/classes/javax/swing/JDialog.java @@ -646,6 +646,7 @@ public class JDialog extends Dialog implements WindowConstants, enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK); setLocale( JComponent.getDefaultLocale() ); setRootPane(createRootPane()); + setBackground(UIManager.getColor("control")); setRootPaneCheckingEnabled(true); if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = diff --git a/src/share/classes/javax/swing/JViewport.java b/src/share/classes/javax/swing/JViewport.java index f8a97e37a..4e5b7240c 100644 --- a/src/share/classes/javax/swing/JViewport.java +++ b/src/share/classes/javax/swing/JViewport.java @@ -25,8 +25,6 @@ package javax.swing; -import sun.swing.JLightweightFrame; - import java.awt.*; import java.awt.event.*; import java.awt.peer.ComponentPeer; @@ -37,10 +35,8 @@ import javax.swing.event.*; import javax.swing.border.*; import javax.accessibility.*; - import java.io.Serializable; - /** * The "viewport" or "porthole" through which you see the underlying * information. When you scroll, what moves is the viewport. It is like @@ -363,18 +359,6 @@ public class JViewport extends JComponent implements Accessible super.remove(child); } - @Override - public void addNotify() { - super.addNotify(); - // JLightweightFrame does not support BLIT_SCROLL_MODE, so it should be replaced - Window rootWindow = SwingUtilities.getWindowAncestor(this); - if (rootWindow instanceof JLightweightFrame - && getScrollMode() == BLIT_SCROLL_MODE) { - setScrollMode(BACKINGSTORE_SCROLL_MODE); - } - } - - /** * Scrolls the view so that <code>Rectangle</code> * within the view becomes visible. @@ -1108,13 +1092,15 @@ public class JViewport extends JComponent implements Accessible Graphics g = JComponent.safelyGetGraphics(this); flushViewDirtyRegion(g, dirty); view.setLocation(newX, newY); - g.setClip(0,0,getWidth(), Math.min(getHeight(), - jview.getHeight())); + Rectangle r = new Rectangle( + 0, 0, getWidth(), Math.min(getHeight(), jview.getHeight())); + g.setClip(r); // Repaint the complete component if the blit succeeded // and needsRepaintAfterBlit returns true. repaintAll = (windowBlitPaint(g) && needsRepaintAfterBlit()); g.dispose(); + rm.notifyRepaintPerformed(this, r.x, r.y, r.width, r.height); rm.markCompletelyClean((JComponent)getParent()); rm.markCompletelyClean(this); rm.markCompletelyClean(jview); diff --git a/src/share/classes/javax/swing/PopupFactory.java b/src/share/classes/javax/swing/PopupFactory.java index 275a1d3c8..99d0359d3 100644 --- a/src/share/classes/javax/swing/PopupFactory.java +++ b/src/share/classes/javax/swing/PopupFactory.java @@ -25,10 +25,14 @@ package javax.swing; +import sun.awt.EmbeddedFrame; +import sun.awt.OSInfo; + import java.applet.Applet; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.security.AccessController; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -226,7 +230,12 @@ public class PopupFactory { case MEDIUM_WEIGHT_POPUP: return getMediumWeightPopup(owner, contents, ownerX, ownerY); case HEAVY_WEIGHT_POPUP: - return getHeavyWeightPopup(owner, contents, ownerX, ownerY); + Popup popup = getHeavyWeightPopup(owner, contents, ownerX, ownerY); + if ((AccessController.doPrivileged(OSInfo.getOSTypeAction()) == + OSInfo.OSType.MACOSX) && (EmbeddedFrame.getAppletIfAncestorOf(owner) != null)) { + ((HeavyWeightPopup)popup).setCacheEnabled(false); + } + return popup; } return null; } @@ -294,6 +303,8 @@ public class PopupFactory { private static final Object heavyWeightPopupCacheKey = new StringBuffer("PopupFactory.heavyWeightPopupCache"); + private volatile boolean isCacheEnabled = true; + /** * Returns either a new or recycled <code>Popup</code> containing * the specified children. @@ -448,12 +459,23 @@ public class PopupFactory { } } + /** + * Enables or disables cache for current object. + */ + void setCacheEnabled(boolean enable) { + isCacheEnabled = enable; + } + // // Popup methods // public void hide() { super.hide(); - recycleHeavyWeightPopup(this); + if (isCacheEnabled) { + recycleHeavyWeightPopup(this); + } else { + this._dispose(); + } } /** diff --git a/src/share/classes/javax/swing/RepaintManager.java b/src/share/classes/javax/swing/RepaintManager.java index 5f103d968..c65c826eb 100644 --- a/src/share/classes/javax/swing/RepaintManager.java +++ b/src/share/classes/javax/swing/RepaintManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, 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 @@ -45,6 +45,8 @@ import sun.misc.SharedSecrets; import sun.security.action.GetPropertyAction; import com.sun.java.swing.SwingUtilities3; +import sun.swing.SwingAccessor; +import sun.swing.SwingUtilities2.RepaintListener; /** * This class manages repaint requests, allowing the number @@ -184,6 +186,17 @@ public class RepaintManager static { + SwingAccessor.setRepaintManagerAccessor(new SwingAccessor.RepaintManagerAccessor() { + @Override + public void addRepaintListener(RepaintManager rm, RepaintListener l) { + rm.addRepaintListener(l); + } + @Override + public void removeRepaintListener(RepaintManager rm, RepaintListener l) { + rm.removeRepaintListener(l); + } + }); + volatileImageBufferEnabled = "true".equals(AccessController. doPrivileged(new GetPropertyAction( "swing.volatileImageBufferEnabled", "true"))); @@ -1267,6 +1280,33 @@ public class RepaintManager getPaintManager().copyArea(c, g, x, y, w, h, deltaX, deltaY, clip); } + private java.util.List<RepaintListener> repaintListeners = new ArrayList<>(1); + + private void addRepaintListener(RepaintListener l) { + repaintListeners.add(l); + } + + private void removeRepaintListener(RepaintListener l) { + repaintListeners.remove(l); + } + + /** + * Notify the attached repaint listeners that an area of the {@code c} component + * has been immediately repainted, that is without scheduling a repaint runnable, + * due to performing a "blit" (via calling the {@code copyArea} method). + * + * @param c the component + * @param x the x coordinate of the area + * @param y the y coordinate of the area + * @param w the width of the area + * @param h the height of the area + */ + void notifyRepaintPerformed(JComponent c, int x, int y, int w, int h) { + for (RepaintListener l : repaintListeners) { + l.repaintPerformed(c, x, y, w, h); + } + } + /** * Invoked prior to any paint/copyArea method calls. This will * be followed by an invocation of <code>endPaint</code>. diff --git a/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java index d036a5e0d..9d34a4dd5 100644 --- a/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java +++ b/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java @@ -806,9 +806,8 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { // Paint the background for the tab area if ( tabPane.isOpaque() ) { - Color bg = UIManager.getColor("TabbedPane.tabAreaBackground"); - if (bg != null) { - g.setColor(bg); + if (!c.isBackgroundSet() && (tabAreaBackground != null)) { + g.setColor(tabAreaBackground); } else { g.setColor( c.getBackground() ); |