1 7 8 package com.sun.java.swing.plaf.windows; 9 10 import java.awt.*; 11 12 import javax.swing.*; 13 import javax.swing.plaf.basic.BasicPopupMenuSeparatorUI ; 14 import javax.swing.plaf.ComponentUI ; 15 16 import com.sun.java.swing.plaf.windows.TMSchema.Part; 17 import com.sun.java.swing.plaf.windows.TMSchema.State; 18 import com.sun.java.swing.plaf.windows.XPStyle.Skin; 19 20 27 28 public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { 29 30 public static ComponentUI createUI(JComponent c) { 31 return new WindowsPopupMenuSeparatorUI(); 32 } 33 34 public void paint(Graphics g, JComponent c) { 35 Dimension s = c.getSize(); 36 if (WindowsMenuItemUI.isVistaPainting()) { 37 int x = 1; 38 Component parent = c.getParent(); 39 if (parent instanceof JComponent) { 40 Object gutterOffsetObject = 41 ((JComponent) parent).getClientProperty( 42 WindowsPopupMenuUI.GUTTER_OFFSET_KEY); 43 if (gutterOffsetObject instanceof Integer ) { 44 49 x = ((Integer ) gutterOffsetObject).intValue() - c.getX(); 50 x += WindowsPopupMenuUI.getGutterWidth(); 51 } 52 } 53 Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR); 54 int skinHeight = skin.getHeight(); 55 int y = (s.height - skinHeight) / 2; 56 skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL); 57 } else { 58 int y = s.height / 2; 59 g.setColor(c.getForeground()); 60 g.drawLine(1, y - 1, s.width - 2, y - 1); 61 62 g.setColor(c.getBackground()); 63 g.drawLine(1, y, s.width - 2, y); 64 } 65 } 66 67 public Dimension getPreferredSize(JComponent c) { 68 int fontHeight = c.getFontMetrics(c.getFont()).getHeight(); 69 70 return new Dimension(0, fontHeight/2 + 2); 71 } 72 73 } 74 | Popular Tags |