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