7. buttonPanel.add(startButton);
buttonPanel.add(stopButton);
// create the main panel
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(timerPanel, BorderLayout.NORTH);
mainPanel.add(namePanel, BorderLayout.CENTER);
mainPanel.add(fontSizePanel, BorderLayout.SOUTH);
// add the sub-panels to the main panel
mainPanel.add(animationPanel, BorderLayout.EAST);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
// add the main panel to the frame and show the frame
frame.add(mainPanel);
frame.setVisible(true);
// add a window listener to the frame to show a message when the program exits
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
timer.stop();
String time = timerLabel.getText().substring(7);
JOptionPane.showMessageDialog(frame, "Thank you for using my program for " + time + "
time.");
frame.setVisible(true);
}
});