| 1 |
/* |
| 2 |
* @(#)EclipsePopupMenuSeparatorUI.java |
| 3 |
* |
| 4 |
* Copyright 2002 JIDE Software Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
|
| 7 |
package com.jidesoft.plaf.eclipse; |
| 8 |
|
| 9 |
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.getColor("PopupMenuSeparator.foreground"); |
| 33 |
Color background = UIDefaultsLookup.getColor("PopupMenuSeparator.background"); |
| 34 |
|
| 35 |
g.setColor(background); |
| 36 |
g.drawLine(1, 0, s.width - 2, 0); |
| 37 |
|
| 38 |
g.setColor(foreground); |
| 39 |
g.drawLine(1, 1, s.width - 2, 1); |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
public Dimension getPreferredSize(JComponent c) { |
| 44 |
return new Dimension(0, 2); |
| 45 |
} |
| 46 |
|
| 47 |
} |