1. /*
  2. * @(#)WindowsTabbedPaneUI.java 1.13 03/01/23
  3. *
  4. * Copyright 2003 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.plaf.basic.*;
  10. import javax.swing.plaf.*;
  11. import javax.swing.*;
  12. /**
  13. * Windows rendition of the component.
  14. * <p>
  15. * <strong>Warning:</strong>
  16. * Serialized objects of this class will not be compatible with
  17. * future Swing releases. The current serialization support is appropriate
  18. * for short term storage or RMI between applications running the same
  19. * version of Swing. A future release of Swing will provide support for
  20. * long term persistence.
  21. */
  22. public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
  23. public static ComponentUI createUI(JComponent c) {
  24. return new WindowsTabbedPaneUI();
  25. }
  26. protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex,
  27. int x, int y, int w, int h, boolean isSelected ) {
  28. if (XPStyle.getXP() == null) {
  29. super.paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
  30. }
  31. }
  32. protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
  33. int x, int y, int w, int h, boolean isSelected ) {
  34. XPStyle xp = XPStyle.getXP();
  35. if (xp != null) {
  36. XPStyle.Skin skin = xp.getSkin("tab.tabitem");
  37. int rotate = 0;
  38. int tx = 0;
  39. int ty = 0;
  40. switch (tabPlacement) {
  41. case RIGHT: rotate = 90; tx = w; break;
  42. case BOTTOM: rotate = 180; tx = w; ty = h; break;
  43. case LEFT: rotate = 270; ty = h; break;
  44. }
  45. g.translate(x+tx, y+ty);
  46. if (rotate != 0 && (g instanceof Graphics2D)) {
  47. ((Graphics2D)g).rotate(Math.toRadians((double)rotate));
  48. }
  49. if (rotate == 90 || rotate == 270) {
  50. skin.paintSkin(g, 0, 0, h, w, isSelected ? 2 : 0);
  51. } else {
  52. skin.paintSkin(g, 0, 0, w, h, isSelected ? 2 : 0);
  53. }
  54. if (rotate != 0 && (g instanceof Graphics2D)) {
  55. ((Graphics2D)g).rotate(-Math.toRadians((double)rotate));
  56. }
  57. g.translate(-x-tx, -y-ty);
  58. } else {
  59. super.paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
  60. }
  61. }
  62. }