1 7 8 package javax.swing.plaf.basic; 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.ComponentUI ; 17 import javax.swing.plaf.SeparatorUI ; 18 19 20 28 29 public class BasicSeparatorUI extends SeparatorUI 30 { 31 protected Color shadow; 32 protected Color highlight; 33 34 public static ComponentUI createUI( JComponent c ) 35 { 36 return new BasicSeparatorUI (); 37 } 38 39 public void installUI( JComponent c ) 40 { 41 installDefaults( (JSeparator)c ); 42 installListeners( (JSeparator)c ); 43 } 44 45 public void uninstallUI(JComponent c) 46 { 47 uninstallDefaults( (JSeparator)c ); 48 uninstallListeners( (JSeparator)c ); 49 } 50 51 protected void installDefaults( JSeparator s ) 52 { 53 LookAndFeel.installColors( s, "Separator.background", "Separator.foreground" ); 54 LookAndFeel.installProperty( s, "opaque", Boolean.FALSE); 55 } 56 57 protected void uninstallDefaults( JSeparator s ) 58 { 59 } 60 61 protected void installListeners( JSeparator s ) 62 { 63 } 64 65 protected void uninstallListeners( JSeparator s ) 66 { 67 } 68 69 public void paint( Graphics g, JComponent c ) 70 { 71 Dimension s = c.getSize(); 72 73 if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL ) 74 { 75 g.setColor( c.getForeground() ); 76 g.drawLine( 0, 0, 0, s.height ); 77 78 g.setColor( c.getBackground() ); 79 g.drawLine( 1, 0, 1, s.height ); 80 } 81 else { 83 g.setColor( c.getForeground() ); 84 g.drawLine( 0, 0, s.width, 0 ); 85 86 g.setColor( c.getBackground() ); 87 g.drawLine( 0, 1, s.width, 1 ); 88 } 89 } 90 91 public Dimension getPreferredSize( JComponent c ) 92 { 93 if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL ) 94 return new Dimension ( 2, 0 ); 95 else 96 return new Dimension ( 0, 2 ); 97 } 98 99 public Dimension getMinimumSize( JComponent c ) { return null; } 100 public Dimension getMaximumSize( JComponent c ) { return null; } 101 } 102 103 104 105 106 | Popular Tags |