GridBagLayout layOut = new GridBagLayout();
getContentPane().setLayout(layOut);
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1.0;
c.fill = GridBagConstraints.BOTH;
primLabel = new JLabel();
primLabel.setText("Primitive");
Font newFont = getFont().deriveFont(1);
primLabel.setFont(newFont);
primLabel.setHorizontalAlignment(JLabel.CENTER);
layOut.setConstraints(primLabel, c);
getContentPane().add(primLabel);
lineLabel = new JLabel();
lineLabel.setText("Lines");
lineLabel.setFont(newFont);
lineLabel.setHorizontalAlignment(JLabel.CENTER);
layOut.setConstraints(lineLabel, c);
getContentPane().add(lineLabel);
c.gridwidth = GridBagConstraints.RELATIVE;
paintLabel = new JLabel();
paintLabel.setText("Paints");
paintLabel.setFont(newFont);
paintLabel.setHorizontalAlignment(JLabel.CENTER);
layOut.setConstraints(paintLabel, c);
getContentPane().add(paintLabel);
c.gridwidth = GridBagConstraints.REMAINDER;
strokeLabel = new JLabel();
strokeLabel.setText("Rendering");
strokeLabel.setFont(newFont);
strokeLabel.setHorizontalAlignment(JLabel.CENTER);
layOut.setConstraints(strokeLabel, c);
getContentPane().add(strokeLabel);
GridBagConstraints ls = new GridBagConstraints();
ls.weightx = 1.0;
ls.fill = GridBagConstraints.BOTH;
primitive = new JComboBox( new Object []{
"rectangle",
"ellipse",
"text"});
primitive.addItemListener(this);
newFont = newFont.deriveFont(0, 14.0f);
primitive.setFont(newFont);
layOut.setConstraints(primitive, ls);
getContentPane().add(primitive);
line = new JComboBox( new Object []{
"thin",
"thick",
"dashed"});
line.addItemListener(this);
line.setFont(newFont);
layOut.setConstraints(line, ls);
getContentPane().add(line);
ls.gridwidth = GridBagConstraints.RELATIVE;
paint = new JComboBox( new Object[]{
"solid",
"gradient",
"polka"});
paint.addItemListener(this);
paint.setFont(newFont);
layOut.setConstraints(paint, ls);
getContentPane().add(paint);
ls.gridwidth = GridBagConstraints.REMAINDER;
stroke = new JComboBox( new Object[]{
"Stroke",
"Fill",
"Stroke & Fill"});
stroke.addItemListener(this);
stroke.setFont(newFont);
layOut.setConstraints(stroke, ls);
getContentPane().add(stroke);
GridBagConstraints sC = new GridBagConstraints();
sC.fill = GridBagConstraints.BOTH;
sC.weightx = 1.0;
sC.weighty = 1.0;
sC.gridwidth = GridBagConstraints.REMAINDER;
display = new ShapePanel();
layOut.setConstraints(display, sC);
display.setBackground(Color.white);
getContentPane().add(display);
validate();