1. /*
  2. * @(#)MetalComboBoxEditor.java 1.14 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 javax.swing.plaf.metal;
  11. import javax.swing.*;
  12. import javax.swing.border.*;
  13. import java.io.Serializable;
  14. import java.awt.*;
  15. import java.awt.event.*;
  16. import javax.swing.plaf.basic.BasicComboBoxEditor;
  17. /**
  18. * The default editor for Metal editable combo boxes
  19. * <p>
  20. * <strong>Warning:</strong>
  21. * Serialized objects of this class will not be compatible with
  22. * future Swing releases. The current serialization support is appropriate
  23. * for short term storage or RMI between applications running the same
  24. * version of Swing. A future release of Swing will provide support for
  25. * long term persistence.
  26. *
  27. * @version 1.14 02/02/00
  28. * @author Steve Wilson
  29. */
  30. public class MetalComboBoxEditor extends BasicComboBoxEditor {
  31. public MetalComboBoxEditor() {
  32. super();
  33. //editor.removeFocusListener(this);
  34. editor = new JTextField("",9);
  35. editor.setBorder( new EditorBorder() );
  36. //editor.addFocusListener(this);
  37. }
  38. protected static Insets editorBorderInsets = new Insets( 2, 2, 2, 0 );
  39. class EditorBorder extends AbstractBorder {
  40. public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
  41. g.translate( x, y );
  42. g.setColor( MetalLookAndFeel.getControlDarkShadow() );
  43. g.drawLine( 0, 0, w-1, 0 );
  44. g.drawLine( 0, 0, 0, h-2 );
  45. g.drawLine( 0, h-2, w-1, h-2 );
  46. g.setColor( MetalLookAndFeel.getControlHighlight() );
  47. g.drawLine( 1, 1, w-1, 1 );
  48. g.drawLine( 1, 1, 1, h-1 );
  49. g.drawLine( 1, h-1, w-1, h-1 );
  50. g.setColor( MetalLookAndFeel.getControl() );
  51. g.drawLine( 1, h-2, 1, h-2 );
  52. g.translate( -x, -y );
  53. }
  54. public Insets getBorderInsets( Component c ) {
  55. return editorBorderInsets;
  56. }
  57. }
  58. /**
  59. * A subclass of BasicComboBoxEditor that implements UIResource.
  60. * BasicComboBoxEditor doesn't implement UIResource
  61. * directly so that applications can safely override the
  62. * cellRenderer property with BasicListCellRenderer subclasses.
  63. * <p>
  64. * <strong>Warning:</strong>
  65. * Serialized objects of this class will not be compatible with
  66. * future Swing releases. The current serialization support is appropriate
  67. * for short term storage or RMI between applications running the same
  68. * version of Swing. A future release of Swing will provide support for
  69. * long term persistence.
  70. */
  71. public static class UIResource extends MetalComboBoxEditor
  72. implements javax.swing.plaf.UIResource {
  73. }
  74. }