Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Automatic merge of client:master into master
  • Loading branch information
duke committed Jul 15, 2020
2 parents 1314319 + 13bcda4 commit 42535d03f351c9c705c06852c1c3086082735ce5
@@ -25,6 +25,7 @@
package javax.swing.plaf.nimbus;

import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
import java.awt.Color;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
@@ -39,7 +40,7 @@
* @author Jasper Potts
*/
@SuppressWarnings("serial") // Same-version serialization only
class DerivedColor extends Color {
class DerivedColor extends Color implements UIResource {
private final String uiDefaultParentName;
private final float hOffset, sOffset, bOffset;
private final int aOffset;
@@ -24,20 +24,26 @@
*/
package javax.swing.plaf.nimbus;

import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JToolBar;
import javax.swing.Painter;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthIcon;

import javax.swing.plaf.synth.SynthContext;
import javax.swing.*;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.plaf.UIResource;

/**
* An icon that delegates to a painter.
* @author rbair
*/
class NimbusIcon implements SynthIcon {
class NimbusIcon implements SynthIcon, UIResource {
private int width;
private int height;
private String prefix;
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2020, 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 javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.UIResource;

/**
* @test
* @bug 8041701
* @summary Nimbus JTree renderer properties persist across L&F changes
* @key headful
* @run main NimbusPropertiesDoNotImplUIResource
*/

public class NimbusPropertiesDoNotImplUIResource {
private static final String[] defPropertyKeys = new String[] {
"Tree.leafIcon", "Tree.closedIcon",
"Tree.openIcon", "Tree.selectionForeground",
"Tree.textForeground", "Tree.selectionBackground",
"Tree.textBackground", "Tree.selectionBorderColor"};

public static void main(String[] args) throws Exception {
UIManager.LookAndFeelInfo[] installedLookAndFeels;
installedLookAndFeels = UIManager.getInstalledLookAndFeels();

for (UIManager.LookAndFeelInfo LF : installedLookAndFeels) {
try {
UIManager.setLookAndFeel(LF.getClassName());
for (String propertyKey : defPropertyKeys) {
verifyProperty(propertyKey);
}
} catch(UnsupportedLookAndFeelException e) {
System.out.println("Note: LookAndFeel " + LF.getClassName()
+ " is not supported on this configuration");
}
}

}

private static void verifyProperty(String propertyKey) {
Object property = UIManager.get(propertyKey);
if (property == null) {
return;
}
if (!(property instanceof UIResource)) {
throw new RuntimeException("Property '"+ propertyKey
+"' is instance of '"+property.getClass()
+"' instead of UIResource.");
}
}
}

0 comments on commit 42535d0

Please sign in to comment.