Listing 1. VerticalSeparator Class
import java.applet.Applet;
import java.awt.* ;
public class VerticalSeparator extends Applet {
private Color _light ;
private Color _dark ;
public void paint( Graphics g ) {
g.setColor( Color.gray ) ;
Dimension size = size() ;
_light =
getBackground().brighter().brighter();
_dark = a
getBackground().darker().darker();
int length = size.height ;
int xPosition = ( size.width )/2 ;
g.setColor( _dark ) ;
g.drawLine( xPosition, 0, xPosition,
length ) ;
g.setColor( _light ) ;
g.drawLine( xPosition+1, 0, xPosition+1,
length ) ;
}
public Dimension getPreferredSize() {
return new Dimension( 4,8 ) ;
}
public Dimension getMinimumSize() {
return getPreferredSize() ;
}
}
Copyright © 1994 - 2018 Linux Journal. All rights reserved.