1. /*
  2. * @(#)WindowsToolBarUI.java 1.14 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.windows;
  8. import java.awt.*;
  9. import javax.swing.JComponent;
  10. import javax.swing.JToggleButton;
  11. import javax.swing.UIDefaults;
  12. import javax.swing.UIManager;
  13. import javax.swing.border.Border;
  14. import javax.swing.border.CompoundBorder;
  15. import javax.swing.border.EmptyBorder;
  16. import javax.swing.plaf.*;
  17. import javax.swing.plaf.basic.BasicBorders;
  18. import javax.swing.plaf.basic.BasicToolBarUI;
  19. public class WindowsToolBarUI extends BasicToolBarUI {
  20. public static ComponentUI createUI(JComponent c) {
  21. return new WindowsToolBarUI();
  22. }
  23. protected void installDefaults() {
  24. if (XPStyle.getXP() != null) {
  25. setRolloverBorders(true);
  26. }
  27. super.installDefaults();
  28. }
  29. protected Border createRolloverBorder() {
  30. if (XPStyle.getXP() != null) {
  31. return new EmptyBorder(3, 3, 3, 3);
  32. } else {
  33. return super.createRolloverBorder();
  34. }
  35. }
  36. protected Border createNonRolloverBorder() {
  37. if (XPStyle.getXP() != null) {
  38. return new EmptyBorder(3, 3, 3, 3);
  39. } else {
  40. return super.createNonRolloverBorder();
  41. }
  42. }
  43. public void paint(Graphics g, JComponent c) {
  44. XPStyle xp = XPStyle.getXP();
  45. if (xp != null) {
  46. String category = "toolbar";
  47. String subCategory = (String)c.getClientProperty("XPStyle.subClass");
  48. if (subCategory != null) {
  49. category = subCategory + "::" + category;
  50. }
  51. xp.getSkin(category).paintSkin(g, 0, 0, c.getSize().width, c.getSize().height, 0);
  52. } else {
  53. super.paint(g, c);
  54. }
  55. }
  56. }