-
Notifications
You must be signed in to change notification settings - Fork 0
/
TwixtManual.java
executable file
·86 lines (74 loc) · 2.39 KB
/
TwixtManual.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* TwixtManual.java
*
* CSE Fall 2007
* Game Project
* @author Steven Speicher
* @version 1.0
*/
//-------------------
// Import Statements
//-------------------
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TwixtManual extends JFrame implements ActionListener
{
//----------------------
// Private data members
//----------------------
private JButton okButton;
private JTextArea gameInfoText;
private JLabel headingLabel,invalidMoveLabel,invalidMoveLabel2,invalidMoveText;
private ImageIcon invalidMoveImageIcon,invalidMoveImageIcon2;
//-------------
// Constructor
//-------------
public TwixtManual()
{
setTitle("Twixt - Game Manual");
setSize(600,600);
setVisible(true);
setLocation(100,100);
setBackground(Color.white);
Container contentPane;
contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
headingLabel = new JLabel("Invalid Moves");
headingLabel.setLayout(new FlowLayout(FlowLayout.RIGHT));
invalidMoveLabel = new JLabel();
invalidMoveLabel.setLayout(new BorderLayout());
invalidMoveImageIcon = new ImageIcon("invalidMove.gif");
JLabel imageLabel = new JLabel(invalidMoveImageIcon);
invalidMoveLabel.add(imageLabel,BorderLayout.CENTER);
invalidMoveLabel2 = new JLabel();
invalidMoveLabel2.setLayout(new FlowLayout());
invalidMoveImageIcon2 = new ImageIcon("invalidMove2.gif");
JLabel imageLabel2 = new JLabel(invalidMoveImageIcon2);
invalidMoveLabel2.add(imageLabel2);
okButton = new JButton("OK");
okButton.addActionListener(this);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(okButton);
JPanel gameInfo = new JPanel(new GridLayout(2,2));
gameInfo.add(invalidMoveLabel);
gameInfo.add(invalidMoveLabel2);
contentPane.add(headingLabel,BorderLayout.NORTH);
contentPane.add(gameInfo,BorderLayout.CENTER);
contentPane.add(buttonPanel,BorderLayout.SOUTH);
}
//----------------
//Action Performed
//----------------
public void actionPerformed(ActionEvent event)
{
if(event.getSource() instanceof JButton){
JButton clickedButton = (JButton) event.getSource();
String buttonText = clickedButton.getText();
if(buttonText.equals("OK")){
this.dispose();
}
}
}
}