8078269: JTabbedPane UI Property TabbedPane.tabAreaBackground no longer works
authorssadetsky
Tue, 09 Jun 2015 18:57:54 +0300
changeset 31431 22615e4a6ab7
parent 31430 66b012d00bd3
child 31432 15d0fd22179a
8078269: JTabbedPane UI Property TabbedPane.tabAreaBackground no longer works Reviewed-by: serb, alexsch
jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
jdk/test/javax/swing/JTabbedPane/8007563/Test8007563.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java	Tue Jun 09 14:11:11 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java	Tue Jun 09 18:57:54 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, 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
@@ -896,11 +896,12 @@
 
         // Paint the background for the tab area
         if ( tabPane.isOpaque() ) {
-            if (!c.isBackgroundSet() && (tabAreaBackground != null)) {
+            Color background = c.getBackground();
+            if (background instanceof UIResource && tabAreaBackground != null) {
                 g.setColor(tabAreaBackground);
             }
             else {
-                g.setColor( c.getBackground() );
+                g.setColor(background);
             }
             switch ( tabPlacement ) {
             case LEFT:
--- a/jdk/test/javax/swing/JTabbedPane/8007563/Test8007563.java	Tue Jun 09 14:11:11 2015 +0300
+++ b/jdk/test/javax/swing/JTabbedPane/8007563/Test8007563.java	Tue Jun 09 18:57:54 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -21,9 +21,7 @@
  * questions.
  */
 
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Robot;
+import java.awt.*;
 import java.util.ArrayList;
 import java.util.concurrent.CountDownLatch;
 import javax.swing.JFrame;
@@ -119,6 +117,20 @@
             }
 
         }
-        invokeLater(this);
+        SecondaryLoop secondaryLoop =
+                Toolkit.getDefaultToolkit().getSystemEventQueue()
+                        .createSecondaryLoop();
+        new Thread() {
+            @Override
+            public void run() {
+                try {
+                    Thread.sleep(200);
+                } catch (InterruptedException e) {
+                }
+                secondaryLoop.exit();
+                invokeLater(Test8007563.this);
+            }
+        }.start();
+        secondaryLoop.enter();
     }
 }