import javax.swing.*;import java.awt.*;import java.awt.event.*;public class TakeAwayGUI extends JFrame implements ActionListener {    private JTextArea display;    private JTextField inField;    private JButton goButton;    private TakeAwayGame game;	        public TakeAwayGUI(String title) {        game = new TakeAwayGame(21);      	buildGUI();        setTitle(title);        pack();        show();    }            private void buildGUI() {        Container contentPane = getContentPane();    	contentPane.setLayout(new BorderLayout());        display = new JTextArea(20,30);        display.setText("Let's play Take Away. There are " + game.sticksLeft() + "sticks.\n" +                        "You go first.\n");        inField = new JTextField(10);        inField.addActionListener(this);        goButton = new JButton("Take Away!");        goButton.addActionListener(this);        JPanel inputPanel = new JPanel();        inputPanel.add(new JLabel("How many sticks do you take: "));        inputPanel.add(inField);        inputPanel.add(goButton);        contentPane.add("Center", display);        contentPane.add("South", inputPanel);    }        public void actionPerformed(ActionEvent e) {	int sticksLeft = 0;        if (e.getSource() == goButton || e.getSource() == inField) {	    String inString = inField.getText();            int userTakes = Integer.parseInt(inString);            game.takeAway(userTakes);            sticksLeft = game.sticksLeft();            display.append("There are " + sticksLeft + " sticks left.\n");            if (sticksLeft <= 0) {                display.append("Game over. I win. Nice game.\n");	    } else {                int computerTakes = 1 + (int)(Math.random() * 3);                game.takeAway(computerTakes);                sticksLeft = game.sticksLeft();                display.append("I take " + computerTakes + ". ");                display.append("There are " + sticksLeft + " sticks left.\n");                if (sticksLeft <= 0) {                    display.append("Game over. You win. Nice game.\n");                }            }        }        if (sticksLeft <= 0) {            goButton.setEnabled(false);            inField.setEnabled(false);        }    }}