1. /*
  2. * @(#)WindowsInternalFrameUI.java 1.23 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 java.beans.*;
  10. import javax.swing.*;
  11. import javax.swing.border.*;
  12. import javax.swing.plaf.basic.*;
  13. import javax.swing.plaf.ComponentUI;
  14. /**
  15. * Windows rendition of the component.
  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. public class WindowsInternalFrameUI extends BasicInternalFrameUI
  25. {
  26. XPStyle xp = XPStyle.getXP();
  27. public void installDefaults() {
  28. super.installDefaults();
  29. if (xp != null) {
  30. frame.setBorder(new XPBorder());
  31. } else {
  32. frame.setBorder(UIManager.getBorder("InternalFrame.border"));
  33. }
  34. }
  35. public void installUI(JComponent c) {
  36. super.installUI(c);
  37. LookAndFeel.installProperty(c, "opaque",
  38. xp == null? Boolean.TRUE : Boolean.FALSE);
  39. }
  40. public void uninstallDefaults() {
  41. frame.setBorder(null);
  42. super.uninstallDefaults();
  43. }
  44. public static ComponentUI createUI(JComponent b) {
  45. return new WindowsInternalFrameUI((JInternalFrame)b);
  46. }
  47. public WindowsInternalFrameUI(JInternalFrame w){
  48. super(w);
  49. }
  50. protected DesktopManager createDesktopManager(){
  51. return new WindowsDesktopManager();
  52. }
  53. protected JComponent createNorthPane(JInternalFrame w) {
  54. titlePane = new WindowsInternalFrameTitlePane(w);
  55. return titlePane;
  56. }
  57. private class XPBorder extends AbstractBorder {
  58. private XPStyle.Skin leftSkin = xp.getSkin("window.frameleft");
  59. private XPStyle.Skin rightSkin = xp.getSkin("window.frameright");
  60. private XPStyle.Skin bottomSkin = xp.getSkin("window.framebottom");
  61. /**
  62. * @param x the x position of the painted border
  63. * @param y the y position of the painted border
  64. * @param width the width of the painted border
  65. * @param height the height of the painted border
  66. */
  67. public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  68. boolean isSelected = ((JInternalFrame)c).isSelected();
  69. int topBorderHeight = (titlePane != null) ? titlePane.getSize().height : 0;
  70. bottomSkin.paintSkin(g, 0, height-bottomSkin.getHeight(),
  71. width, bottomSkin.getHeight(),
  72. isSelected ? 0 : 1);
  73. leftSkin.paintSkin(g, 0, topBorderHeight-1,
  74. leftSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
  75. isSelected ? 0 : 1);
  76. rightSkin.paintSkin(g, width-rightSkin.getWidth(), topBorderHeight-1,
  77. rightSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
  78. isSelected ? 0 : 1);
  79. }
  80. public Insets getBorderInsets(Component c) {
  81. return getBorderInsets(c, new Insets(0, 0, 0, 0));
  82. }
  83. public Insets getBorderInsets(Component c, Insets insets) {
  84. insets.top = 4;
  85. insets.left = leftSkin.getWidth();
  86. insets.right = rightSkin.getWidth();
  87. insets.bottom = bottomSkin.getHeight();
  88. return insets;
  89. }
  90. public boolean isBorderOpaque() {
  91. return true;
  92. }
  93. }
  94. }