1. /*
  2. * @(#)WindowsBorders.java 1.13 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package com.sun.java.swing.plaf.windows;
  11. import javax.swing.*;
  12. import javax.swing.border.*;
  13. import javax.swing.plaf.*;
  14. import javax.swing.plaf.basic.*;
  15. import java.awt.Component;
  16. import java.awt.Insets;
  17. import java.awt.Dimension;
  18. import java.awt.Rectangle;
  19. import java.awt.Color;
  20. import java.awt.Graphics;
  21. import java.io.Serializable;
  22. /**
  23. * Factory object that can vend Borders appropriate for the Windows 95 L & F.
  24. * @version 1.13 02/02/00
  25. * @author Rich Schiavi
  26. */
  27. public class WindowsBorders {
  28. public static class ComboBoxBorder implements Border, UIResource {
  29. protected Color shadow;
  30. protected Color darkShadow;
  31. protected Color highlight;
  32. public ComboBoxBorder(Color shadow, Color darkShadow, Color highlight) {
  33. this.shadow = shadow;
  34. this.darkShadow = darkShadow;
  35. this.highlight = highlight;
  36. }
  37. public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
  38. Rectangle b = c.getBounds();
  39. BasicGraphicsUtils.drawEtchedRect(g,0,0,b.width,b.height,
  40. c.getBackground(), shadow,
  41. darkShadow, highlight);
  42. }
  43. public Insets getBorderInsets(Component c) {
  44. return new Insets( 2, 2, 2, 2 );
  45. }
  46. public boolean isBorderOpaque() {
  47. return true;
  48. }
  49. }
  50. public static class ProgressBarBorder extends AbstractBorder implements UIResource {
  51. protected Color shadow;
  52. protected Color highlight;
  53. public ProgressBarBorder(Color shadow, Color highlight) {
  54. this.highlight = highlight;
  55. this.shadow = shadow;
  56. }
  57. public void paintBorder(Component c, Graphics g, int x, int y,
  58. int width, int height) {
  59. g.setColor(shadow);
  60. g.drawLine(x,y, width-1,y); // draw top
  61. g.drawLine(x,y, x,height-1); // draw left
  62. g.setColor(highlight);
  63. g.drawLine(x,height-1, width-1,height-1); // draw bottom
  64. g.drawLine(width-1,y, width-1,height-1); // draw right
  65. }
  66. public Insets getBorderInsets(Component c) {
  67. return new Insets(1,1,1,1);
  68. }
  69. }
  70. }