container.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import javax.swing.LookAndFeel;
  2. import javax.swing.UIManager;
  3. public class container {
  4. static int exitVal = 0;
  5. /**
  6. * Tests the UIManager a bit. Doing this kills a lot of OpenJDK builds.
  7. *
  8. * Note these functions are used in a headless application, a web app.
  9. * The fonts are needed to create PDFs reliably.
  10. *
  11. * If this succeeds, the first line it prints to stdout is Success
  12. * and it returns a return code (exit value) of 0 (zero)
  13. *
  14. * If there's a failure, the first line consists of Failed, and the return code is 1 (one)
  15. */
  16. public static void main(String[] args) {
  17. try {
  18. String family = UIManager.getFont("Label.font").getFamily();
  19. } catch (Throwable t) {
  20. bad("Could not get the default font's family", t);
  21. }
  22. try {
  23. LookAndFeel look = UIManager.getLookAndFeel();
  24. } catch (Throwable t) {
  25. bad("Error getting the look and feel class name", t);
  26. }
  27. try {
  28. LookAndFeel metal = new javax.swing.plaf.metal.MetalLookAndFeel();
  29. UIManager.setLookAndFeel(metal);
  30. String family = UIManager.getFont("Label.font").getFamily();
  31. } catch (Throwable t) {
  32. bad("Error making a Metal look/feel, setting it to the UIManager, or getting its font...", t);
  33. }
  34. System.exit(exitVal);
  35. }
  36. private static void bad(String msg, Throwable t) {
  37. exitVal = 1;
  38. System.err.println(msg);
  39. t.printStackTrace(System.err);
  40. }
  41. }