7200491: Tighten up JTable layout code
authorrupashka
Tue, 06 Nov 2012 15:30:34 +0400
changeset 16088 8edf3fb360ea
parent 16087 89b565a23835
child 16089 7cf1e2708454
7200491: Tighten up JTable layout code Reviewed-by: art, skoivu
jdk/src/share/classes/javax/swing/JTable.java
jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
--- a/jdk/src/share/classes/javax/swing/JTable.java	Fri Nov 02 16:50:23 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/JTable.java	Tue Nov 06 15:30:34 2012 +0400
@@ -781,15 +781,11 @@
                         scrollPane.getCorner(JScrollPane.UPPER_TRAILING_CORNER);
                 if (corner == null || corner instanceof UIResource){
                     corner = null;
-                    Object componentClass = UIManager.get(
-                            "Table.scrollPaneCornerComponent");
-                    if (componentClass instanceof Class){
-                        try {
-                            corner = (Component)
-                                    ((Class)componentClass).newInstance();
-                        } catch (Exception e) {
-                            // just ignore and don't set corner
-                        }
+                    try {
+                        corner = (Component) UIManager.get(
+                                "Table.scrollPaneCornerComponent");
+                    } catch (Exception e) {
+                        // just ignore and don't set corner
                     }
                     scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER,
                             corner);
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java	Fri Nov 02 16:50:23 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java	Tue Nov 06 15:30:34 2012 +0400
@@ -159,7 +159,12 @@
 
             // Store Table ScrollPane Corner Component
             uiDefaults.put("Table.scrollPaneCornerComponent",
-                    TableScrollPaneCorner.class);
+                    new UIDefaults.ActiveValue() {
+                        @Override
+                        public Object createValue(UIDefaults table) {
+                            return new TableScrollPaneCorner();
+                        }
+                    });
 
             // Setup the settings for ToolBarSeparator which is custom
             // installed for Nimbus