01: /*
02: * @(#)EclipsePopupMenuSeparatorUI.java
03: *
04: * Copyright 2002 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.plaf.eclipse;
08:
09: import com.jidesoft.plaf.UIDefaultsLookup;
10:
11: import javax.swing.*;
12: import javax.swing.plaf.ComponentUI;
13: import javax.swing.plaf.basic.BasicSeparatorUI;
14: import java.awt.*;
15:
16: /**
17: * PopupMenuSeparator UI implementation
18: */
19: public class EclipsePopupMenuSeparatorUI extends BasicSeparatorUI {
20: public static ComponentUI createUI(JComponent c) {
21: return new EclipsePopupMenuSeparatorUI();
22: }
23:
24: @Override
25: public void paint(Graphics g, JComponent c) {
26: if (!(c.getParent() instanceof JPopupMenu)) {
27: super .paint(g, c);
28: }
29:
30: Dimension s = c.getSize();
31:
32: Color foreground = UIDefaultsLookup
33: .getColor("PopupMenuSeparator.foreground");
34: Color background = UIDefaultsLookup
35: .getColor("PopupMenuSeparator.background");
36:
37: g.setColor(background);
38: g.drawLine(1, 0, s.width - 2, 0);
39:
40: g.setColor(foreground);
41: g.drawLine(1, 1, s.width - 2, 1);
42: }
43:
44: @Override
45: public Dimension getPreferredSize(JComponent c) {
46: return new Dimension(0, 2);
47: }
48:
49: }
|