01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Anton Avtamonov
20: * @version $Revision$
21: */package javax.swing.plaf.metal;
22:
23: import java.awt.Component;
24: import java.awt.Graphics;
25: import java.awt.Insets;
26:
27: import javax.swing.border.AbstractBorder;
28: import javax.swing.border.Border;
29: import javax.swing.plaf.basic.BasicComboBoxEditor;
30: import javax.swing.plaf.basic.BasicGraphicsUtils;
31:
32: public class MetalComboBoxEditor extends BasicComboBoxEditor {
33:
34: public static class UIResource extends MetalComboBoxEditor
35: implements javax.swing.plaf.UIResource {
36: }
37:
38: protected static Insets editorBorderInsets = new Insets(4, 2, 4, 0);
39: private static Border border = new AbstractBorder() {
40: public Insets getBorderInsets(final Component component) {
41: return editorBorderInsets;
42: }
43:
44: public Insets getBorderInsets(final Component component,
45: final Insets insets) {
46: if (insets == null) {
47: return getBorderInsets(component);
48: }
49: insets
50: .set(editorBorderInsets.top,
51: editorBorderInsets.left,
52: editorBorderInsets.bottom,
53: editorBorderInsets.right);
54: return insets;
55: }
56:
57: public void paintBorder(final Component c, final Graphics g,
58: final int x, final int y, final int width,
59: final int height) {
60: BasicGraphicsUtils.drawGroove(g, x, y, width, height,
61: MetalLookAndFeel.getControlDarkShadow(),
62: MetalLookAndFeel.getControlHighlight());
63: }
64: };
65:
66: public MetalComboBoxEditor() {
67: editor.setBorder(border);
68: }
69: }
|