D:\JavaII\YahtzeeGame\src\yahtzeegame\Driver.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package yahtzeegame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author Owner
*/
public class Driver extends JFrame implements ActionListener {
private static final int FRAME_WIDTH = 700;
private static final int FRAME_HEIGHT = 500;
private static final int X_AXIS = 0;
private static final int Y_AXIS = 0;
private static final int FIELD_WIDTH1 = 10;
JMenu fileMenu, aboutMenu;
JLabel displayTurn, displayRoll, ones,
twos, threes, fours, fives, sixes, threeKind,
fourKind, fullHouse, smStraight, lgStraight, yahtzee, chance,
dice1, dice2, dice3, dice4, dice5;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Driver frame = new Driver();
frame.setVisible(true);
}
public Driver(){
setTitle("Yahtzee!");
setSize(FRAME_WIDTH, FRAME_HEIGHT);
setLocation(X_AXIS, Y_AXIS);
setResizable(false);
addComponents(getContentPane());
createFileMenu();
JMenuBar menuBar = new JMenuBar();
setJMenuBar (menuBar);
menuBar.add(fileMenu);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent event){
}
private void createFileMenu()
{
JMenuItem item;
fileMenu = new JMenu("File");
item = new JMenuItem("New Game");
item.addActionListener(this);
fileMenu.add(item);
fileMenu.addSeparator();
item = new JMenuItem("Quit");
item.addActionListener(this);
fileMenu.add(item);
}
public void addComponents(Container contentPane){
contentPane.setLayout(new BorderLayout());
JLabel turn, roll;
JRadioButton hold1, hold2, hold3, hold4, hold5;
JButton rollDice, onesBtn, twosBtn, threesBtn, foursBtn, fivesBtn, sixesBtn, threeKindBtn, fourKindBtn, fullHouseBtn, smStraightBtn, lgStraightBtn, chanceBtn, yahtzeeBtn;
JPanel scoringLeft, scoringRight, diceDisplay;
scoringLeft = new JPanel();
scoringLeft.setBackground(Color.white);
scoringLeft.setLayout(new GridLayout(14,1));
turn = new JLabel("Turn #:");
scoringLeft.add(turn);
displayTurn = new JLabel("");
scoringLeft.add(displayTurn);
onesBtn = new JButton("Ones:");
scoringLeft.add(onesBtn);
ones = new JLabel("");
scoringLeft.add(ones);
twosBtn = new JButton("Twos:");
scoringLeft.add(twosBtn);
twos = new JLabel("");
scoringLeft.add(twos);
threesBtn = new JButton("Threes:");
scoringLeft.add(threesBtn);
threes = new JLabel("");
scoringLeft.add(threes);
foursBtn = new JButton("Fours:");
scoringLeft.add(foursBtn);
fours = new JLabel("");
scoringLeft.add(fours);
fivesBtn = new JButton("Fives:");
scoringLeft.add(fivesBtn);
fives = new JLabel("");
scoringLeft.add(fives);
sixesBtn = new JButton("Sixes:");
scoringLeft.add(sixesBtn);
sixes = new JLabel("");
scoringLeft.add(sixes);
contentPane.add(scoringLeft, BorderLayout.WEST);
scoringRight = new JPanel();
scoringRight.setLayout(new GridLayout(14,1));
scoringRight.setBackground(Color.white);
roll = new JLabel("Roll #:");
scoringRight.add(roll);
displayRoll = new JLabel("");
scoringRight.add(displayRoll);
threeKindBtn = new JButton("3 of a Kind:");
scoringRight.add(threeKindBtn);
threeKind = new JLabel("");
scoringRight.add(threeKind);
fourKindBtn = new JButton("4 of a Kind:");
scoringRight.add(fourKindBtn);
fourKind = new JLabel("");
scoringRight.add(fourKind);
fullHouseBtn = new JButton("Full House:");
scoringRight.add(fullHouseBtn);
fullHouse = new JLabel("");
scoringRight.add(fullHouse);
smStraightBtn = new JButton("Sm. Straight:");
scoringRight.add(smStraightBtn);
smStraight = new JLabel("");
scoringRight.add(smStraight);
lgStraightBtn = new JButton("Lg. Straight:");
scoringRight.add(lgStraightBtn);
lgStraight = new JLabel("");
scoringRight.add(lgStraight);
yahtzeeBtn = new JButton("Yahtzee:");
scoringRight.add(yahtzeeBtn);
yahtzee = new JLabel("");
scoringRight.add(yahtzee);
chanceBtn = new JButton("Chance:");
scoringRight.add(chanceBtn);
chance = new JLabel("");
scoringRight.add(chance);
contentPane.add(scoringRight, BorderLayout.EAST);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}