01: /*
02: * Copyright (C) 2004 NNL Technology AB
03: * Visit www.infonode.net for information about InfoNode(R)
04: * products and how to contact NNL Technology AB.
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19: * MA 02111-1307, USA.
20: */
21:
22: // $Id: PopupMenuBorder.java,v 1.7 2005/12/04 13:46:03 jesper Exp $
23: package net.infonode.gui.border;
24:
25: import net.infonode.gui.GraphicsUtil;
26:
27: import javax.swing.border.Border;
28: import java.awt.*;
29: import java.io.Serializable;
30:
31: /**
32: * @author $Author: jesper $
33: * @version $Revision: 1.7 $
34: */
35: public class PopupMenuBorder implements Border, Serializable {
36: private static final long serialVersionUID = 1;
37:
38: private static final Insets INSETS = new Insets(3, 1, 2, 1);
39:
40: private Color highlightColor;
41: private Color shadowColor;
42:
43: public PopupMenuBorder(Color highlightColor, Color shadowColor) {
44: this .highlightColor = highlightColor;
45: this .shadowColor = shadowColor;
46: }
47:
48: public boolean isBorderOpaque() {
49: return false;
50: }
51:
52: public void paintBorder(Component c, Graphics g, int x, int y,
53: int width, int height) {
54: g.setColor(shadowColor);
55: g.drawRect(x, y, width - 1, height - 1);
56:
57: g.setColor(highlightColor);
58: GraphicsUtil.drawOptimizedLine(g, x + 1, y + 1, x + width - 2,
59: y + 1);
60: GraphicsUtil.drawOptimizedLine(g, x + 1, y + 2, x + 1, y + 2);
61: GraphicsUtil.drawOptimizedLine(g, x + 1, y + height - 2, x + 1,
62: y + height - 2);
63: }
64:
65: public Insets getBorderInsets(Component c) {
66: return INSETS;
67: }
68: }
|