getContentPane().setLayout( new BorderLayout() );
JPanel topPanel = new JPanel();
JPanel fontPanel = new JPanel();
JPanel sizePanel = new JPanel();
JPanel stylePanel = new JPanel();
JPanel sizeAndStylePanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
fontPanel.setLayout( new GridLayout( 2, 1 ) );
sizePanel.setLayout( new GridLayout( 2, 1 ) );
stylePanel.setLayout( new GridLayout( 2, 1 ) );
sizeAndStylePanel.setLayout( new BorderLayout() );
topPanel.add( BorderLayout.WEST, fontPanel );
sizeAndStylePanel.add( BorderLayout.WEST, sizePanel );
sizeAndStylePanel.add( BorderLayout.CENTER, stylePanel );
topPanel.add( BorderLayout.CENTER, sizeAndStylePanel );
getContentPane().add( BorderLayout.NORTH, topPanel );
fontLabel = new JLabel();
fontLabel.setText("Fonts");
Font newFont = getFont().deriveFont(1);
fontLabel.setFont(newFont);
fontLabel.setHorizontalAlignment(JLabel.CENTER);
fontPanel.add(fontLabel);
sizeLabel = new JLabel();
sizeLabel.setText("Sizes");
sizeLabel.setFont(newFont);
sizeLabel.setHorizontalAlignment(JLabel.CENTER);
sizePanel.add(sizeLabel);
styleLabel = new JLabel();
styleLabel.setText("Styles");
styleLabel.setFont(newFont);
styleLabel.setHorizontalAlignment(JLabel.CENTER);
stylePanel.add(styleLabel);
GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
String envfonts[] = gEnv.getAvailableFontFamilyNames();
Vector vector = new Vector();
for ( int i = 1; i < envfonts.length; i++ ) {
vector.addElement(envfonts[i]);
}
fonts = new JComboBox( vector );
fonts.setMaximumRowCount( 9 );
fonts.addItemListener(this);
fontchoice = envfonts[0];
fontPanel.add(fonts);
sizes = new JComboBox( new Object[]{ "10", "12", "14", "16", "18"} );
sizes.setMaximumRowCount( 9 );
sizes.addItemListener(this);
sizePanel.add(sizes);
styles = new JComboBox( new Object[]{
"PLAIN",
"BOLD",
"ITALIC",
"BOLD & ITALIC"} );
styles.setMaximumRowCount( 9 );
styles.addItemListener(this);
sizes.setMaximumRowCount( 9 );
stylePanel.add(styles);
fontC = new FontPanel();
fontC.setBackground(Color.white);
getContentPane().add( BorderLayout.CENTER, fontC);