1. package org.jr.awt.icon;
  2. /**
  3. * Copyright: Copyright (c) 2002-2004
  4. * Company: JavaResearch(http://www.javaresearch.org)
  5. * 最后更新日期:2003年2月16日
  6. * @author Cherami
  7. */
  8. import java.awt.*;
  9. import javax.swing.*;
  10. import javax.swing.plaf.metal.*;
  11. /**
  12. * 被禁止的文件夹图标。
  13. * @since 0.1
  14. */
  15. public class DisabledFolderIcon
  16. implements Icon {
  17. int width = 16;
  18. int height = 16;
  19. int additionalHeight = 2;
  20. /**
  21. * 绘制图标
  22. * @param c 绘制组件
  23. * @param g 图形设备
  24. * @param x 绘制的x坐标的起始点
  25. * @param y 绘制的y坐标的起始点
  26. * @since 0.1
  27. */
  28. public void paintIcon(Component c, Graphics g, int x, int y) {
  29. int right = width - 1;
  30. int bottom = height - 2;
  31. g.setColor(c.getBackground());
  32. g.fillRect(0, 0, width, getIconHeight());
  33. // Draw tab
  34. g.setColor(MetalLookAndFeel.getControlDisabled());
  35. g.drawLine(right - 5, 2, right, 2);
  36. g.drawLine(right - 6, 3, right - 6, 4);
  37. g.drawLine(right, 3, right, 4);
  38. // Draw outline
  39. g.setColor(MetalLookAndFeel.getControlDisabled());
  40. g.drawLine(0, 5, 0, bottom); // left side
  41. g.drawLine(1, 4, right - 7, 4); // first part of top
  42. g.drawLine(right - 6, 5, right - 1, 5); // second part of top
  43. g.drawLine(right, 4, right, bottom); // right side
  44. g.drawLine(0, bottom, right, bottom); // bottom
  45. }
  46. /**
  47. * 图标宽度。
  48. * @return 图标宽度
  49. * @since 0.1
  50. */
  51. public int getIconWidth() {
  52. return width;
  53. }
  54. /**
  55. * 图标高度。
  56. * @return 图标高度
  57. * @since 0.1
  58. */
  59. public int getIconHeight() {
  60. return height + additionalHeight;
  61. }
  62. }