import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.DecimalFormat; public class Main extends JFrame implements ActionListener { private CrapsGame game; private JTextField input; private JTextArea display; // Constructor public Main() { super("Craps: Test 1"); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new JLabel("Next roll:")); input = new JTextField(5); input.setBackground(Color.YELLOW); input.addActionListener(this); c.add(input); display = new JTextArea(10, 20); display.setEditable(false); display.setBackground(Color.WHITE); c.add(new JScrollPane(display, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); game = new CrapsGame(); } // Called when a number is enetered into the JTextField input // public void actionPerformed(ActionEvent e) { String s = input.getText().trim(); int total = Integer.parseInt(s); int result = game.processRoll(total); int point = game.getPoint(); input.setText(""); display.append(total + ": Result = " + result + " Point = " + point + "\n"); } public static void main(String[] args) { Main window = new Main(); window.setBounds(100, 100, 300, 240); window.setDefaultCloseOperation(EXIT_ON_CLOSE); window.setResizable(false); window.setVisible(true); } }