1. /*
  2. * @(#)WindowsBorders.java 1.12 01/11/29
  3. *
  4. * Copyright 2002 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 javax.swing.*;
  9. import javax.swing.border.*;
  10. import javax.swing.plaf.*;
  11. import javax.swing.plaf.basic.*;
  12. import java.awt.Component;
  13. import java.awt.Insets;
  14. import java.awt.Dimension;
  15. import java.awt.Rectangle;
  16. import java.awt.Color;
  17. import java.awt.Graphics;
  18. import java.io.Serializable;
  19. /**
  20. * Factory object that can vend Borders appropriate for the Windows 95 L & F.
  21. * @version 1.12 11/29/01
  22. * @author Rich Schiavi
  23. */
  24. public class WindowsBorders {
  25. public static class ComboBoxBorder implements Border, UIResource {
  26. protected Color shadow;
  27. protected Color darkShadow;
  28. protected Color highlight;
  29. public ComboBoxBorder(Color shadow, Color darkShadow, Color highlight) {
  30. this.shadow = shadow;
  31. this.darkShadow = darkShadow;
  32. this.highlight = highlight;
  33. }
  34. public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
  35. Rectangle b = c.getBounds();
  36. BasicGraphicsUtils.drawEtchedRect(g,0,0,b.width,b.height,
  37. c.getBackground(), shadow,
  38. darkShadow, highlight);
  39. }
  40. public Insets getBorderInsets(Component c) {
  41. return new Insets( 2, 2, 2, 2 );
  42. }
  43. public boolean isBorderOpaque() {
  44. return true;
  45. }
  46. }
  47. public static class ProgressBarBorder extends AbstractBorder implements UIResource {
  48. protected Color shadow;
  49. protected Color highlight;
  50. public ProgressBarBorder(Color shadow, Color highlight) {
  51. this.highlight = highlight;
  52. this.shadow = shadow;
  53. }
  54. public void paintBorder(Component c, Graphics g, int x, int y,
  55. int width, int height) {
  56. g.setColor(shadow);
  57. g.drawLine(x,y, width-1,y); // draw top
  58. g.drawLine(x,y, x,height-1); // draw left
  59. g.setColor(highlight);
  60. g.drawLine(x,height-1, width-1,height-1); // draw bottom
  61. g.drawLine(width-1,y, width-1,height-1); // draw right
  62. }
  63. public Insets getBorderInsets(Component c) {
  64. return new Insets(1,1,1,1);
  65. }
  66. }
  67. }