1 7 8 package javax.swing.plaf.metal; 9 10 import javax.swing.*; 11 import java.awt.Color ; 12 import java.awt.Dimension ; 13 import java.awt.Graphics ; 14 import java.awt.Insets ; 15 import java.awt.Rectangle ; 16 import javax.swing.plaf.*; 17 import javax.swing.plaf.basic.BasicSeparatorUI ; 18 19 20 36 37 public class MetalSeparatorUI extends BasicSeparatorUI 38 { 39 public static ComponentUI createUI( JComponent c ) 40 { 41 return new MetalSeparatorUI (); 42 } 43 44 protected void installDefaults( JSeparator s ) 45 { 46 LookAndFeel.installColors( s, "Separator.background", "Separator.foreground" ); 47 } 48 49 public void paint( Graphics g, JComponent c ) 50 { 51 Dimension s = c.getSize(); 52 53 if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL ) 54 { 55 g.setColor( c.getForeground() ); 56 g.drawLine( 0, 0, 0, s.height ); 57 58 g.setColor( c.getBackground() ); 59 g.drawLine( 1, 0, 1, s.height ); 60 } 61 else { 63 g.setColor( c.getForeground() ); 64 g.drawLine( 0, 0, s.width, 0 ); 65 66 g.setColor( c.getBackground() ); 67 g.drawLine( 0, 1, s.width, 1 ); 68 } 69 } 70 71 public Dimension getPreferredSize( JComponent c ) 72 { 73 if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL ) 74 return new Dimension ( 2, 0 ); 75 else 76 return new Dimension ( 0, 2 ); 77 } 78 } 79 80 81 82 83 | Popular Tags |