34 * Since changes to the system LAF are a once in a blue moon event,
35 * this test is useful to tell us of unexpected problems.
36 * Note: this test must be run in a headful environment
37 * since otherwise a system LAF may not be available.
38 */
39
40 public class SystemLookAndFeelTest {
41
42 public static void main(String[] args) {
43
44 String laf = javax.swing.UIManager.getSystemLookAndFeelClassName();
45 String os = System.getProperty("os.name").toLowerCase();
46 System.out.println("OS is " + os);
47 System.out.println("Reported System LAF is " + laf);
48
49 String expLAF = null;
50 if (os.contains("windows")) {
51 expLAF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
52 } else if (os.contains("macos")) {
53 expLAF = "com.apple.laf.AquaLookAndFeel";
54 } else if (os.contains("linux") || os.contains("sunos")) {
55 /*
56 * The implementation keys off the following desktop setting to
57 * decide if GTK is an appropriate system L&F.
58 * In its absence, there probably isn't support for the GTK L&F
59 * anyway. It does not tell us if the GTK libraries are available
60 * but they really should be if this is a gnome session.
61 * If it proves necessary the test can perhaps be updated to see
62 * if the GTK LAF is listed as installed and can be instantiated.
63 */
64 String gnome = System.getenv("GNOME_DESKTOP_SESSION_ID");
65 System.out.println("Gnome desktop session ID is " + gnome);
66 if (gnome != null) {
67 expLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
68 } else if (os.contains("linux")) {
69 expLAF = "javax.swing.plaf.metal.MetalLookAndFeel";
70 } else if (os.contains("sunos")) {
71 expLAF = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
72 }
73 }
74 System.out.println("Expected System LAF is " + expLAF);
75 if (expLAF == null) {
76 System.out.println("No match for expected LAF, unknown OS ?");
77 return;
78 }
79 if (!(laf.equals(expLAF))) {
80 throw new RuntimeException("LAF not as expected");
81 }
82 }
83 }
|
34 * Since changes to the system LAF are a once in a blue moon event,
35 * this test is useful to tell us of unexpected problems.
36 * Note: this test must be run in a headful environment
37 * since otherwise a system LAF may not be available.
38 */
39
40 public class SystemLookAndFeelTest {
41
42 public static void main(String[] args) {
43
44 String laf = javax.swing.UIManager.getSystemLookAndFeelClassName();
45 String os = System.getProperty("os.name").toLowerCase();
46 System.out.println("OS is " + os);
47 System.out.println("Reported System LAF is " + laf);
48
49 String expLAF = null;
50 if (os.contains("windows")) {
51 expLAF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
52 } else if (os.contains("macos")) {
53 expLAF = "com.apple.laf.AquaLookAndFeel";
54 } else if (os.contains("linux")) {
55 /*
56 * The implementation keys off the following desktop setting to
57 * decide if GTK is an appropriate system L&F.
58 * In its absence, there probably isn't support for the GTK L&F
59 * anyway. It does not tell us if the GTK libraries are available
60 * but they really should be if this is a gnome session.
61 * If it proves necessary the test can perhaps be updated to see
62 * if the GTK LAF is listed as installed and can be instantiated.
63 */
64 String gnome = System.getenv("GNOME_DESKTOP_SESSION_ID");
65 System.out.println("Gnome desktop session ID is " + gnome);
66 if (gnome != null) {
67 expLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
68 } else if (os.contains("linux")) {
69 expLAF = "javax.swing.plaf.metal.MetalLookAndFeel";
70 }
71 }
72 System.out.println("Expected System LAF is " + expLAF);
73 if (expLAF == null) {
74 System.out.println("No match for expected LAF, unknown OS ?");
75 return;
76 }
77 if (!(laf.equals(expLAF))) {
78 throw new RuntimeException("LAF not as expected");
79 }
80 }
81 }
|