I can't make the string show up when the "Enter message" button is clicked, and I can't center the box for some reason. When I click the Draw square it will draw the square and if I click "Draw it in color" it will draw it in color. However no matter what I do, the text will not appear. Here's my code:
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
public class Lab9 extends JApplet implements ActionListener, ItemListener {
 private JRadioButton square;
 private JRadioButton message;
 private JTextField messageField;
 private String messageEntered = "";
 private JComboBox location;
 private JPanel top;
 private JPanel bottom;
 private JCheckBox drawColor;
 private JButton draw;
 private int newWidth;
 private int newHeight;
 private static final String locations[] = {"Centered", "Random location"};
 private boolean drawSquare;
 private Color color;
@Override
public void init() {
    setLayout(new FlowLayout());
    top = new JPanel();
    bottom = new JPanel();
    square = new JRadioButton("Draw square");
    square.addItemListener(this);
    top.add(square);
    message = new JRadioButton("Enter your message:");
    message.addItemListener(this);
    top.add(message);
    messageField = new JTextField(20);
    messageField.addActionListener(this);
    top.add(messageField);
    //bottom panel
    bottom.add(new JLabel("Select where to draw:"));
    location = new JComboBox(locations);
    bottom.add(location);
    drawColor = new JCheckBox("Draw in color");
    drawColor.addItemListener(this);
    bottom.add(drawColor);
    draw = new JButton("Draw it!");
    draw.addActionListener(this);
    bottom.add(draw);
    add(top);
    add(bottom);
}
 @Override 
 public void paint(Graphics g) {
     super.paint(g); 
     g.setColor(color);
     if(drawSquare){
         g.fillRect(newWidth, newHeight, 200, 200);
     }
     else {
         g.setColor(color);
         g.drawString(messageEntered, newWidth, newHeight); // print out entered name 
     }
 }
@Override
public void actionPerformed(ActionEvent e) {
    repaint();
}
@Override
public void itemStateChanged(ItemEvent e) {
    int width = getWidth();
    int height = getHeight();
    Random rand = new Random();
    if(e.getSource() == location && location.getSelectedIndex() == 1) {
         newWidth = rand.nextInt(width) + 20;
         newHeight = rand.nextInt(height) + 20;
    }
    if (e.getSource() == location && location.getSelectedIndex() == 0) {
        newWidth = width/2-100;
        newHeight = height/2-100;
    }
    if(e.getSource() == square && e.getStateChange() == ItemEvent.SELECTED) {
        drawSquare = true;
    }
    if(e.getSource() == message && e.getStateChange() == ItemEvent.SELECTED) {
        drawSquare = false;
        messageEntered = messageField.getText();
    }
    if (e.getSource() == drawColor && e.getStateChange() == ItemEvent.SELECTED) {
        color = new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
    }
    if(e.getSource() == drawColor && e.getStateChange() == ItemEvent.DESELECTED) {
        color = Color.BLACK;
    }
}
Suggestions?
 
    