1
1
/*
2
- * Copyright (c) 2012, 2013 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2012, 2020 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
25
25
* @test
26
26
* @bug 4726194 7124209
27
27
* @summary Tests for 4726194
28
- * @author Phil Milne
29
28
*/
30
- import java .awt .*;
31
- import java .lang .reflect .InvocationTargetException ;
32
- import java .util .*;
29
+
30
+ import java .awt .Font ;
31
+ import java .util .ArrayList ;
32
+ import java .util .Arrays ;
33
33
import java .util .List ;
34
- import javax .swing .*;
34
+
35
+ import javax .swing .BorderFactory ;
36
+ import javax .swing .JTextField ;
37
+ import javax .swing .Spring ;
38
+ import javax .swing .SpringLayout ;
39
+ import javax .swing .SwingUtilities ;
40
+ import javax .swing .UIManager ;
41
+ import javax .swing .UnsupportedLookAndFeelException ;
42
+
43
+ import static javax .swing .UIManager .getInstalledLookAndFeels ;
35
44
36
45
public class bug4726194 {
37
46
@@ -40,22 +49,29 @@ public class bug4726194 {
40
49
private static int [] FAIL = new int [3 ];
41
50
private static boolean TEST_DUPLICATES = false ;
42
51
43
- public static void main (String [] args ) {
44
- try {
45
- SwingUtilities .invokeAndWait (new Runnable () {
46
- @ Override
47
- public void run () {
48
- int minLevel = 2 ;
49
- int maxLevel = 2 ;
50
- for (int i = minLevel ; i <= maxLevel ; i ++) {
51
- test (i , true );
52
- test (i , false );
53
- }
52
+ public static void main (String [] args ) throws Exception {
53
+ for (final UIManager .LookAndFeelInfo laf : getInstalledLookAndFeels ()) {
54
+ SwingUtilities .invokeAndWait (() -> setLookAndFeel (laf ));
55
+ SwingUtilities .invokeAndWait (() -> {
56
+ int minLevel = 2 ;
57
+ int maxLevel = 2 ;
58
+ for (int i = minLevel ; i <= maxLevel ; i ++) {
59
+ test (i , true );
60
+ test (i , false );
54
61
}
55
62
});
56
- } catch (InterruptedException | InvocationTargetException ex ) {
57
- ex .printStackTrace ();
58
- throw new RuntimeException ("FAILED: SwingUtilities.invokeAndWait method failed!" );
63
+ }
64
+ }
65
+
66
+ private static void setLookAndFeel (UIManager .LookAndFeelInfo laf ) {
67
+ try {
68
+ System .out .println ("LookAndFeel: " + laf .getClassName ());
69
+ UIManager .setLookAndFeel (laf .getClassName ());
70
+ } catch (UnsupportedLookAndFeelException ignored ){
71
+ System .out .println ("Unsupported LookAndFeel: " + laf .getClassName ());
72
+ } catch (ClassNotFoundException | InstantiationException |
73
+ IllegalAccessException e ) {
74
+ throw new RuntimeException (e );
59
75
}
60
76
}
61
77
@@ -64,6 +80,7 @@ public static void test(int level, boolean horizontal) {
64
80
String [] constraints = horizontal ? hConstraints : vConstraints ;
65
81
test (level , constraints , result , Arrays .asList (new Object [level ]));
66
82
JTextField tf = new JTextField ("" );
83
+ tf .setBorder (BorderFactory .createEmptyBorder ());
67
84
tf .setFont (new Font ("Dialog" , Font .PLAIN , 6 ));
68
85
System .out .print ("\t \t " );
69
86
for (int j = 0 ; j < constraints .length ; j ++) {
0 commit comments