What's the secret to using JSeparator?
- From: lee@xxxxxxxxxx (Lee Weiner)
- Date: Sat, 31 Dec 2005 20:25:52 GMT
The API documentation for JSeparator says that, besides using it in menus, it
can be used "elsewhere in a GUI wherever a visual divider is useful." I have
never been able to use it (show a visible divider) except in a menu. Anyone
know the "secret of the separator"?
A short, contrived example follows:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class SeparatorTest extends JFrame
{
public SeparatorTest( )
{
setTitle( "SeparatorTest" );
setSize( 200, 200 );
setLocationRelativeTo( null );
JPanel pnlCenter = new JPanel();
pnlCenter.add( new JLabel( "Last Name: " ) );
pnlCenter.add( new JTextField( 8 ) );
pnlCenter.add( new JLabel( "First Name: " ) );
pnlCenter.add( new JTextField( 8 ) );
JSeparator sep = new JSeparator( JSeparator.HORIZONTAL );
pnlCenter.add( sep );
pnlCenter.add( new JButton( "OK" ) );
pnlCenter.add( new JButton( "Exit" ) );
add( pnlCenter );
}
public static void main(String[] args)
{
SeparatorTest app = new SeparatorTest();
app.setVisible( true );
}
}
Lee Weiner
lee AT leeweiner DOT org
.
- Prev by Date: Re: JForm is a Swing component framework that supports databinding and validation.
- Previous by thread: Action problem
- Index(es):