| 1 |
/* |
| 2 |
* @(#)VsnetPopupMenuSeparatorUI.java |
| 3 |
* |
| 4 |
* Copyright 2002 JIDE Software Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
|
| 7 |
package com.jidesoft.plaf.vsnet; |
| 8 |
|
| 9 |
import com.jidesoft.plaf.UIDefaultsLookup; |
| 10 |
import com.jidesoft.plaf.basic.ThemePainter; |
| 11 |
|
| 12 |
import javax.swing.*; |
| 13 |
import javax.swing.plaf.ComponentUI; |
| 14 |
import javax.swing.plaf.basic.BasicPopupMenuSeparatorUI; |
| 15 |
import java.awt.*; |
| 16 |
|
| 17 |
/** |
| 18 |
* PopupMenuSeparator UI implementation |
| 19 |
*/ |
| 20 |
public class VsnetPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { |
| 21 |
public static final int HEIGHT = 3; |
| 22 |
private ThemePainter _painter; |
| 23 |
|
| 24 |
public static ComponentUI createUI(JComponent c) { |
| 25 |
return new VsnetPopupMenuSeparatorUI(); |
| 26 |
} |
| 27 |
|
| 28 |
@Override |
| 29 |
protected void installDefaults(JSeparator s) { |
| 30 |
_painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter"); |
| 31 |
super.installDefaults(s); |
| 32 |
} |
| 33 |
|
| 34 |
@Override |
| 35 |
protected void uninstallDefaults(JSeparator s) { |
| 36 |
super.uninstallDefaults(s); |
| 37 |
_painter = null; |
| 38 |
} |
| 39 |
|
| 40 |
public ThemePainter getPainter() { |
| 41 |
return _painter; |
| 42 |
} |
| 43 |
|
| 44 |
@Override |
| 45 |
public void paint(Graphics g, JComponent c) { |
| 46 |
if (!(c.getParent() instanceof JPopupMenu)) { |
| 47 |
super.paint(g, c); |
| 48 |
return; |
| 49 |
} |
| 50 |
|
| 51 |
getPainter().paintPopupMenuSeparator(c, g, new Rectangle(0, 0, c.getWidth(), c.getHeight()), SwingConstants.HORIZONTAL, ThemePainter.STATE_DEFAULT); |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
public Dimension getPreferredSize(JComponent c) { |
| 56 |
return new Dimension(0, HEIGHT); |
| 57 |
} |
| 58 |
|
| 59 |
} |