--- old/src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java 2018-06-14 18:59:32.000000000 -0700
+++ new/src/java.desktop/macosx/classes/com/apple/laf/AquaSpinnerUI.java 2018-06-14 18:59:31.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -732,7 +732,8 @@
ui.updateEnabledState();
} else if (JComponent.TOOL_TIP_TEXT_KEY.equals(propertyName)) {
ui.updateToolTipTextForChildren(spinner);
- } else if ("font".equals(propertyName)) {
+ } else if ("font".equals(propertyName) ||
+ "graphicsConfiguration".equals(propertyName)) {
JComponent editor = spinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
JTextField tf
--- old/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java 2018-06-14 18:59:34.000000000 -0700
+++ new/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java 2018-06-14 18:59:34.000000000 -0700
@@ -3320,7 +3320,7 @@
} else if (name == "indexForNullComponent") {
isRunsDirty = true;
updateHtmlViews((Integer) e.getNewValue(), true);
- } else if (name == "font") {
+ } else if (name == "font" || name == "graphicsConfiguration") {
calculatedBaseline = false;
}
}
--- old/src/java.desktop/share/classes/java/awt/Component.java 2018-06-14 18:59:36.000000000 -0700
+++ new/src/java.desktop/share/classes/java/awt/Component.java 2018-06-14 18:59:36.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2018, 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
@@ -24,65 +24,96 @@
*/
package java.awt;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.Objects;
-import java.util.Vector;
-import java.util.Locale;
-import java.util.EventListener;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Collections;
-import java.awt.peer.ComponentPeer;
-import java.awt.peer.ContainerPeer;
-import java.awt.peer.LightweightPeer;
+import java.applet.Applet;
+import java.awt.dnd.DropTarget;
+import java.awt.event.ActionEvent;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputEvent;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.event.PaintEvent;
+import java.awt.event.TextEvent;
+import java.awt.im.InputContext;
+import java.awt.im.InputMethodRequests;
import java.awt.image.BufferStrategy;
+import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
-import java.awt.image.ColorModel;
import java.awt.image.VolatileImage;
-import java.awt.event.*;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.IOException;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.Transient;
-import java.awt.im.InputContext;
-import java.awt.im.InputMethodRequests;
-import java.awt.dnd.DropTarget;
-import java.security.AccessController;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
import java.security.AccessControlContext;
-import javax.accessibility.*;
-import java.applet.Applet;
+import java.security.AccessController;
+import java.util.Collections;
+import java.util.EventListener;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
import javax.swing.JComponent;
import javax.swing.JRootPane;
-import sun.awt.ComponentFactory;
-import sun.security.action.GetPropertyAction;
-import sun.awt.AppContext;
import sun.awt.AWTAccessor;
+import sun.awt.AppContext;
+import sun.awt.ComponentFactory;
import sun.awt.ConstrainableGraphics;
+import sun.awt.EmbeddedFrame;
+import sun.awt.RequestFocusController;
import sun.awt.SubRegionShowable;
import sun.awt.SunToolkit;
-import sun.awt.EmbeddedFrame;
import sun.awt.dnd.SunDropTargetEvent;
import sun.awt.im.CompositionArea;
+import sun.awt.image.VSyncedBSManager;
import sun.font.FontManager;
import sun.font.FontManagerFactory;
import sun.font.SunFontManager;
import sun.java2d.SunGraphics2D;
+import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.pipe.Region;
-import sun.awt.image.VSyncedBSManager;
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
-import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
-import sun.awt.RequestFocusController;
-import sun.java2d.SunGraphicsEnvironment;
+import sun.security.action.GetPropertyAction;
import sun.swing.SwingAccessor;
import sun.util.logging.PlatformLogger;
+import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType
+ .VSYNC_DEFAULT;
+import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.VSYNC_ON;
+
/**
* A component is an object having a graphical representation
* that can be displayed on the screen and that can interact with the
@@ -1129,24 +1160,31 @@
}
}
- boolean updateGraphicsData(GraphicsConfiguration gc) {
- checkTreeLock();
+ final boolean updateGraphicsData(GraphicsConfiguration gc) {
+ GraphicsConfiguration oldConfig = graphicsConfig;
+ // First, update own graphics configuration
+ boolean ret = updateSelfGraphicsData(gc);
+ // Second, update children graphics configurations
+ ret |= updateChildGraphicsData(gc);
+ // Third, fire PropertyChange if needed
+ if (oldConfig != gc) {
+ /*
+ * If component is moved from one screen to another screen or shown
+ * for the first time graphicsConfiguration property is fired to
+ * enable the component to recalculate any rendering data, if needed
+ */
+ firePropertyChange("graphicsConfiguration", oldConfig, gc);
+ }
+ return ret;
+ }
+ private boolean updateSelfGraphicsData(GraphicsConfiguration gc) {
+ checkTreeLock();
if (graphicsConfig == gc) {
return false;
}
- GraphicsConfiguration oldConfig = graphicsConfig;
graphicsConfig = gc;
- /*
- * If component is moved from one screen to another sceeen
- * graphicsConfiguration property is fired to enable the component
- * to recalculate any rendering data, if needed
- */
- if (oldConfig != null && gc != null) {
- firePropertyChange("graphicsConfiguration", oldConfig, gc);
- }
-
ComponentPeer peer = this.peer;
if (peer != null) {
return peer.updateGraphicsData(gc);
@@ -1154,6 +1192,10 @@
return false;
}
+ boolean updateChildGraphicsData(GraphicsConfiguration gc) {
+ return false;
+ }
+
/**
* Checks that this component's {@code GraphicsDevice}
* {@code idString} matches the string argument.
--- old/src/java.desktop/share/classes/java/awt/Container.java 2018-06-14 18:59:38.000000000 -0700
+++ new/src/java.desktop/share/classes/java/awt/Container.java 2018-06-14 18:59:38.000000000 -0700
@@ -1172,10 +1172,10 @@
}
@Override
- boolean updateGraphicsData(GraphicsConfiguration gc) {
+ final boolean updateChildGraphicsData(GraphicsConfiguration gc) {
checkTreeLock();
- boolean ret = super.updateGraphicsData(gc);
+ boolean ret = false;
for (Component comp : component) {
if (comp != null) {
--- old/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java 2018-06-14 18:59:41.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java 2018-06-14 18:59:40.000000000 -0700
@@ -259,7 +259,9 @@
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
// Strings get interned...
if (propertyName == "text"
- || ((propertyName == "font" || propertyName == "foreground")
+ || ((propertyName == "font"
+ || propertyName == "graphicsConfiguration"
+ || propertyName == "foreground")
&& oldValue != newValue
&& getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicButtonListener.java 2018-06-14 18:59:43.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicButtonListener.java 2018-06-14 18:59:43.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -74,9 +74,8 @@
else if(prop == AbstractButton.CONTENT_AREA_FILLED_CHANGED_PROPERTY) {
checkOpacity((AbstractButton) e.getSource() );
}
- else if(prop == AbstractButton.TEXT_CHANGED_PROPERTY ||
- "font" == prop || "foreground" == prop ||
- "ancestor" == prop || "graphicsConfiguration" == prop) {
+ else if(prop == AbstractButton.TEXT_CHANGED_PROPERTY || "font" == prop
+ || "foreground" == prop || "graphicsConfiguration" == prop) {
AbstractButton b = (AbstractButton) e.getSource();
BasicHTML.updateRenderer(b, b.getText());
}
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java 2018-06-14 18:59:45.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java 2018-06-14 18:59:44.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -1801,7 +1801,8 @@
setPopupVisible(comboBox, true);
}
}
- else if ( propertyName == "font" ) {
+ else if (propertyName == "font"
+ || propertyName == "graphicsConfiguration") {
listBox.setFont( comboBox.getFont() );
if ( editor != null ) {
editor.setFont( comboBox.getFont() );
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicEditorPaneUI.java 2018-06-14 18:59:47.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicEditorPaneUI.java 2018-06-14 18:59:47.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -173,6 +173,7 @@
updateFocusTraversalKeys();
} else if ("foreground".equals(name)
|| "font".equals(name)
+ || "graphicsConfiguration".equals(name)
|| "document".equals(name)
|| JEditorPane.W3C_LENGTH_UNITS.equals(name)
|| JEditorPane.HONOR_DISPLAY_PROPERTIES.equals(name)
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java 2018-06-14 18:59:49.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java 2018-06-14 18:59:49.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -472,8 +472,8 @@
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
- if (name == "text" || "font" == name || "foreground" == name ||
- "ancestor" == name || "graphicsConfiguration" == name) {
+ if (name == "text" || "font" == name || "foreground" == name
+ || "graphicsConfiguration" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java 2018-06-14 18:59:51.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java 2018-06-14 18:59:50.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -2656,7 +2656,8 @@
updateLayoutStateNeeded |= cellRendererChanged;
redrawList();
}
- else if (propertyName == "font") {
+ else if (propertyName == "font"
+ || propertyName == "graphicsConfiguration") {
updateLayoutStateNeeded |= fontChanged;
redrawList();
}
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java 2018-06-14 18:59:53.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java 2018-06-14 18:59:52.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -1105,9 +1105,8 @@
if (name == "labelFor" || name == "displayedMnemonic" ||
name == "accelerator") {
updateAcceleratorBinding();
- } else if (name == "text" || "font" == name ||
- "foreground" == name ||
- "ancestor" == name || "graphicsConfiguration" == name) {
+ } else if (name == "text" || "font" == name || "foreground" == name
+ || "graphicsConfiguration" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java 2018-06-14 18:59:54.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java 2018-06-14 18:59:54.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -1829,6 +1829,7 @@
propertyName == "paintTicks" ||
propertyName == "paintTrack" ||
propertyName == "font" ||
+ propertyName == "graphicsConfiguration" ||
propertyName == "paintLabels" ||
propertyName == "Slider.paintThumbArrowShape") {
checkedLabelBaselines = false;
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java 2018-06-14 18:59:56.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java 2018-06-14 18:59:56.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, 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
@@ -1010,7 +1010,8 @@
"model".equals(propertyName)) {
ui.updateEnabledState();
}
- else if ("font".equals(propertyName)) {
+ else if ("font".equals(propertyName) ||
+ "graphicsConfiguration".equals(propertyName)) {
JComponent editor = spinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
JTextField tf =
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java 2018-06-14 18:59:59.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java 2018-06-14 18:59:58.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -4004,7 +4004,7 @@
} else if (name == "indexForNullComponent") {
isRunsDirty = true;
updateHtmlViews((Integer)e.getNewValue(), true);
- } else if (name == "font") {
+ } else if (name == "font" || name == "graphicsConfiguration") {
calculatedBaseline = false;
}
}
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java 2018-06-14 19:00:01.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java 2018-06-14 19:00:00.000000000 -0700
@@ -1896,7 +1896,8 @@
// Changes in ComponentOrientation require the views to be
// rebuilt.
modelChanged();
- } else if ("font" == propertyName) {
+ } else if ("font" == propertyName
+ || "graphicsConfiguration" == propertyName) {
modelChanged();
} else if ("dropLocation" == propertyName) {
dropIndexChanged();
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolTipUI.java 2018-06-14 19:00:03.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicToolTipUI.java 2018-06-14 19:00:02.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -260,9 +260,9 @@
PropertyChangeListener {
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
- if (name.equals("tiptext") || "font".equals(name) ||
- "foreground".equals(name) ||
- "ancestor" == name || "graphicsConfiguration" == name) {
+ if (name.equals("tiptext") || "foreground".equals(name)
+ || "font".equals(name)
+ || "graphicsConfiguration".equals(name)) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.
--- old/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java 2018-06-14 19:00:04.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTreeUI.java 2018-06-14 19:00:04.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -3843,7 +3843,8 @@
else if(changeName == JTree.SELECTION_MODEL_PROPERTY) {
setSelectionModel(tree.getSelectionModel());
}
- else if(changeName == "font") {
+ else if(changeName == "font"
+ || changeName == "graphicsConfiguration") {
completeEditing();
if(treeState != null)
treeState.invalidateSizes();
--- old/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java 2018-06-14 19:00:06.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java 2018-06-14 19:00:06.000000000 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, 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
@@ -226,9 +226,8 @@
updateStyle((JToolTip)e.getSource());
}
String name = e.getPropertyName();
- if (name.equals("tiptext") || "font".equals(name) ||
- "foreground".equals(name) ||
- "ancestor" == name || "graphicsConfiguration" == name) {
+ if (name.equals("tiptext") || "graphicsConfiguration".equals(name)
+ || "foreground".equals(name) || "font".equals(name)) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.
--- old/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java 2018-06-14 19:00:08.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java 2018-06-14 19:00:08.000000000 -0700
@@ -347,7 +347,9 @@
if (propertyName=="text"
|| propertyName == "labelFor"
|| propertyName == "displayedMnemonic"
- || ((propertyName == "font" || propertyName == "foreground")
+ || ((propertyName == "font"
+ ||propertyName == "graphicsConfiguration"
+ || propertyName == "foreground")
&& oldValue != newValue
&& getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
--- old/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java 2018-06-14 19:00:10.000000000 -0700
+++ new/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java 2018-06-14 19:00:10.000000000 -0700
@@ -690,7 +690,9 @@
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
// Strings get interned...
if (propertyName == "text"
- || ((propertyName == "font" || propertyName == "foreground")
+ || ((propertyName == "font"
+ || propertyName == "graphicsConfiguration"
+ || propertyName == "foreground")
&& oldValue != newValue
&& getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {
--- /dev/null 2018-06-14 19:00:12.000000000 -0700
+++ new/test/jdk/javax/swing/GraphicsConfigNotifier/OrderOfGConfigNotify.java 2018-06-14 19:00:11.000000000 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018, 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 java.awt.EventQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8201552
+ * @summary Container should get "graphicsConfiguration" notification when all
+ * its children are updated
+ */
+public final class OrderOfGConfigNotify {
+
+ private static String name = "graphicsConfiguration";
+
+ public static void main(final String[] args) throws Exception {
+ EventQueue.invokeAndWait(() -> {
+ AtomicBoolean parentCalled = new AtomicBoolean(false);
+ AtomicBoolean childCalled = new AtomicBoolean(false);
+
+ JFrame frame = new JFrame();
+
+ JPanel parent = new JPanel();
+ parent.addPropertyChangeListener(evt -> {
+ if (!evt.getPropertyName().equals(name)) {
+ return;
+ }
+ if (!childCalled.get()) {
+ throw new RuntimeException("Parent is called/child is not");
+ }
+ parentCalled.set(true);
+ if (parent.getGraphicsConfiguration() == null) {
+ throw new RuntimeException("GraphicsConfiguration is null");
+ }
+ });
+ JPanel child = new JPanel();
+ child.addPropertyChangeListener(evt -> {
+ if (!evt.getPropertyName().equals(name)) {
+ return;
+ }
+ childCalled.set(true);
+ if (child.getGraphicsConfiguration() == null) {
+ throw new RuntimeException("GraphicsConfiguration is null");
+ }
+ });
+ parent.add(child);
+
+ // Frame.add() should update graphicsConfiguration for all hierarchy
+ frame.add(parent);
+ if (!parentCalled.get() || !childCalled.get()) {
+ throw new RuntimeException("Property listener was not called");
+ }
+ });
+ }
+}
--- /dev/null 2018-06-14 19:00:13.000000000 -0700
+++ new/test/jdk/javax/swing/GraphicsConfigNotifier/StalePreferredSize.java 2018-06-14 19:00:13.000000000 -0700
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2018, 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 java.awt.Component;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.FlowLayout;
+import java.awt.Font;
+import java.util.Objects;
+import java.util.concurrent.Callable;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JEditorPane;
+import javax.swing.JFormattedTextField;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.JToolTip;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8201552
+ * @summary Initial layout of the component should use correct graphics config.
+ * It is checked by SwingUtilities.updateComponentTreeUI(), if layout
+ * was correct the call to updateComponentTreeUI() will be no-op.
+ * @compile -encoding utf-8 StalePreferredSize.java
+ * @run main StalePreferredSize
+ * @run main/othervm -Dsun.java2d.uiScale=2.25 StalePreferredSize
+ */
+public final class StalePreferredSize {
+
+ static final String HTML =
+ "A few words to get started before the "
+ + "bugoverlapping text";
+
+ // Some text to be tested
+ static String TEXT1 = "A quick brown fox jumps over the lazy dog";
+ static String TEXT2 = "El veloz murciélago hindú comía feliz cardillo y "
+ + "kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja";
+ static String TEXT3 = "Voix ambiguë d’un cœur qui au zéphyr préfère les "
+ + "jattes de kiwis";
+ static String TEXT4 = "다람쥐 헌 쳇바퀴에 타고파";
+ static String TEXT5 = "Съешь ещё этих мягких французских булок да выпей же чаю";
+
+
+ static JFrame frame;
+ static Component component;
+ static int typeFont = 0; // 0 - default, 1 - bold, 2 - italic
+
+ public static void main(final String[] args) throws Exception {
+ for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+ EventQueue.invokeAndWait(() -> setLookAndFeel(laf));
+ for (; typeFont < 3; typeFont++) {
+ System.err.println("typeFont = " + typeFont);
+ test(HTML);
+ test(TEXT1);
+ test(TEXT2);
+ test(TEXT3);
+ test(TEXT4);
+ test(TEXT5);
+ }
+ }
+ }
+
+ private static void test(String text) throws Exception {
+ System.err.println("text = " + text);
+ // Each Callable create a component to be tested
+ Callable[] comps = {
+ () -> new JLabel(text),
+ () -> new JButton(text),
+ () -> new JMenuItem(text),
+ () -> new JMenu(text),
+ () -> new JList<>(new String[]{text}),
+ () -> new JComboBox<>(new String[]{text}),
+ () -> new JTextField(text),
+ () -> new JTextArea(text),
+ () -> new JCheckBox(text),
+ () -> new JFormattedTextField(text),
+ () -> new JRadioButton(text),
+ () -> new JTree(new DefaultMutableTreeNode(text)),
+//TODO () -> new JSpinner(new SpinnerListModel(new String[]{HTML})),
+ () -> {
+ JToolTip tip = new JToolTip();
+ tip.setTipText(text);
+ return tip;
+ },
+ () -> {
+ JEditorPane pane = new JEditorPane();
+ pane.setText(text);
+ return pane;
+ },
+
+ () -> {
+ JTable table = new JTable(1, 1);
+ table.getModel().setValueAt(text, 0, 0);
+ return table;
+ }
+ };
+
+ for (Callable creator : comps) {
+ checkComponent(creator);
+ }
+ }
+
+ static void checkComponent(Callable creator) throws Exception {
+ EventQueue.invokeAndWait(() -> {
+
+ try {
+ component = creator.call();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ if (typeFont == 1) {
+ component.setFont(component.getFont().deriveFont(Font.BOLD));
+ }
+ if (typeFont == 2) {
+ component.setFont(component.getFont().deriveFont(Font.ITALIC));
+ }
+
+ frame = new JFrame();
+ frame.setLayout(new FlowLayout());
+ frame.add(new JScrollPane(component));
+ frame.setSize(300, 100);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ });
+
+ EventQueue.invokeAndWait(() -> {
+
+ // After the frame was shown we change nothing, so current layout
+ // should be optimal and updateComponentTreeUI() should be no-op
+ Dimension before = component.getPreferredSize();
+ SwingUtilities.updateComponentTreeUI(frame);
+ Dimension after = component.getPreferredSize();
+
+ frame.dispose();
+
+ if (!Objects.equals(before, after)) {
+ System.err.println("Component: " + component);
+ System.err.println("Before: " + before);
+ System.err.println("After: " + after);
+ throw new RuntimeException("Wrong PreferredSize");
+ }
+ });
+ }
+
+ private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) {
+ try {
+ UIManager.setLookAndFeel(laf.getClassName());
+ System.err.println("LookAndFeel: " + laf.getClassName());
+ } catch (final UnsupportedLookAndFeelException ignored) {
+ System.err.println(
+ "Unsupported LookAndFeel: " + laf.getClassName());
+ } catch (ClassNotFoundException | InstantiationException |
+ IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
--- /dev/null 2018-06-14 19:00:15.000000000 -0700
+++ new/test/jdk/javax/swing/GraphicsConfigNotifier/TestSingleScreenGConfigNotify.java 2018-06-14 19:00:14.000000000 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2018, 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 java.awt.EventQueue;
+import java.awt.GraphicsConfiguration;
+import java.util.Objects;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8201552
+ * @summary Verifies if graphicsConfiguration property notification is sent
+ * when frame is shown on the screen.
+ * @run main TestSingleScreenGConfigNotify
+ * @run main/othervm -Dsun.java2d.uiScale=2.25 TestSingleScreenGConfigNotify
+ */
+public final class TestSingleScreenGConfigNotify {
+
+ private static String name = "graphicsConfiguration";
+ private static CountDownLatch go = new CountDownLatch(1);
+ private static JFrame frame;
+ private static GraphicsConfiguration after;
+ private static GraphicsConfiguration before;
+ private static JButton button;
+
+ public static void main(final String[] args) throws Exception {
+ EventQueue.invokeAndWait(() -> {
+ frame = new JFrame();
+
+ frame.setSize(300,300);
+ frame.setLocationRelativeTo(null);
+ button = new JButton();
+ button.addPropertyChangeListener(evt -> {
+ if (evt.getPropertyName().equals(name)) {
+ go.countDown();
+ }
+ });
+
+ before = button.getGraphicsConfiguration();
+
+ frame.add(button);
+ frame.setVisible(true);
+ });
+
+ boolean called = go.await(10, TimeUnit.SECONDS);
+
+ EventQueue.invokeAndWait(() -> {
+ after = button.getGraphicsConfiguration();
+ frame.dispose();
+ });
+
+ if (Objects.equals(before, after) && called) {
+ throw new RuntimeException("propertyChange() should not be called");
+ }
+ if (!Objects.equals(before, after) && !called) {
+ throw new RuntimeException("propertyChange() should be called");
+ }
+ }
+}