1. /*
  2. * @(#)DefaultMetalTheme.java 1.18 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.plaf.metal;
  11. import javax.swing.plaf.*;
  12. import javax.swing.*;
  13. import java.awt.*;
  14. /**
  15. * This class describes the default Metal Theme.
  16. * <p>
  17. * <strong>Warning:</strong>
  18. * Serialized objects of this class will not be compatible with
  19. * future Swing releases. The current serialization support is appropriate
  20. * for short term storage or RMI between applications running the same
  21. * version of Swing. A future release of Swing will provide support for
  22. * long term persistence.
  23. *
  24. * @version 1.18 02/02/00
  25. * @author Steve Wilson
  26. */
  27. public class DefaultMetalTheme extends MetalTheme {
  28. private final ColorUIResource primary1 = new ColorUIResource(102, 102, 153);
  29. private final ColorUIResource primary2 = new ColorUIResource(153, 153, 204);
  30. private final ColorUIResource primary3 = new ColorUIResource(204, 204, 255);
  31. private final ColorUIResource secondary1 = new ColorUIResource(102, 102, 102);
  32. private final ColorUIResource secondary2 = new ColorUIResource(153, 153, 153);
  33. private final ColorUIResource secondary3 = new ColorUIResource(204, 204, 204);
  34. private FontUIResource controlFont;
  35. private FontUIResource systemFont;
  36. private FontUIResource userFont;
  37. private FontUIResource smallFont;
  38. public String getName() { return "Steel"; }
  39. public DefaultMetalTheme() { }
  40. // these are blue in Metal Default Theme
  41. protected ColorUIResource getPrimary1() { return primary1; }
  42. protected ColorUIResource getPrimary2() { return primary2; }
  43. protected ColorUIResource getPrimary3() { return primary3; }
  44. // these are gray in Metal Default Theme
  45. protected ColorUIResource getSecondary1() { return secondary1; }
  46. protected ColorUIResource getSecondary2() { return secondary2; }
  47. protected ColorUIResource getSecondary3() { return secondary3; }
  48. // note the properties listed here can currently be used by people
  49. // providing runtimes to hint what fonts are good. For example the bold
  50. // dialog font looks bad on a Mac, so Apple could use this property to
  51. // hint at a good font.
  52. //
  53. // However, we don't promise to support these forever. We may move
  54. // to getting these from the swing.properties file, or elsewhere.
  55. public FontUIResource getControlTextFont() {
  56. if (controlFont == null) {
  57. try {
  58. controlFont = new FontUIResource(Font.getFont("swing.plaf.metal.controlFont", new Font("Dialog", Font.BOLD, 12)));
  59. } catch (Exception e) {
  60. controlFont = new FontUIResource("Dialog", Font.BOLD, 12);
  61. }
  62. }
  63. return controlFont;
  64. }
  65. public FontUIResource getSystemTextFont() {
  66. if (systemFont == null) {
  67. try {
  68. systemFont = new FontUIResource(Font.getFont("swing.plaf.metal.systemFont", new Font("Dialog", Font.PLAIN, 12)));
  69. } catch (Exception e) {
  70. systemFont = new FontUIResource("Dialog", Font.PLAIN, 12);
  71. }
  72. }
  73. return systemFont;
  74. }
  75. public FontUIResource getUserTextFont() {
  76. if (userFont == null) {
  77. try {
  78. userFont = new FontUIResource(Font.getFont("swing.plaf.metal.userFont", new Font("Dialog", Font.PLAIN, 12)));
  79. } catch (Exception e) {
  80. userFont = new FontUIResource("Dialog", Font.PLAIN, 12);
  81. }
  82. }
  83. return userFont;
  84. }
  85. public FontUIResource getMenuTextFont() {
  86. if (controlFont == null) {
  87. try {
  88. controlFont = new FontUIResource(Font.getFont("swing.plaf.metal.controlFont", new Font("Dialog", Font.BOLD, 12)));
  89. } catch (Exception e) {
  90. controlFont = new FontUIResource("Dialog", Font.BOLD, 12);
  91. }
  92. }
  93. return controlFont;
  94. }
  95. public FontUIResource getWindowTitleFont() {
  96. if (controlFont == null) {
  97. try {
  98. controlFont = new FontUIResource(Font.getFont("swing.plaf.metal.controlFont", new Font("Dialog", Font.BOLD, 12)));
  99. } catch (Exception e) {
  100. controlFont = new FontUIResource("Dialog", Font.BOLD, 12);
  101. }
  102. }
  103. return controlFont;
  104. }
  105. public FontUIResource getSubTextFont() {
  106. if (smallFont == null) {
  107. try {
  108. smallFont = new FontUIResource(Font.getFont("swing.plaf.metal.smallFont", new Font("Dialog", Font.PLAIN, 10)));
  109. } catch (Exception e) {
  110. smallFont = new FontUIResource("Dialog", Font.PLAIN, 10);
  111. }
  112. }
  113. return smallFont;
  114. }
  115. }