-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeScreenApplet.java
81 lines (61 loc) · 1.93 KB
/
HomeScreenApplet.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
// The "HomeScreenApplet" class.
import java.awt.*;
import java.applet.*;
import java.awt.Image;
public class HomeScreenApplet extends Applet
{
//Variables
// A Button to click
Button bSinglePlayer;
Button bMultiPlayer;
// A textField to get text input
TextField moneyField;
int startMoney; // Stores the amount of starting cash
// A group of radio buttons
// necessary to only allow one radio button to be selected at the same time.
CheckboxGroup radioGroup;
// The radio buttons to be selected
Checkbox radio1;
Checkbox radio2;
// An independant selection box
Checkbox option;
//Background image
Image background;
Graphics g;
public void init ()
{
// Tell the applet not to use a layout manager.
setLayout (null);
// initialze the button and give it a text.
bSinglePlayer = new Button ("Single Player");
bMultiPlayer = new Button ("Multi Player");
// text and length of the field
moneyField = new TextField ("Starting Cash", 10);
// initialize the radio buttons group
radioGroup = new CheckboxGroup ();
// first radio button. Gives the label text, tells to which
// group it belongs and sets the default state (unselected)
radio1 = new Checkbox ("Radio1", radioGroup, false);
// same but selected
radio2 = new Checkbox ("Radio2", radioGroup, true);
// Label and state of the checkbox
option = new Checkbox ("Option", false);
bSinglePlayer.setBounds (20, 20, 100, 30);
bMultiPlayer.setBounds (20,220, 100, 30);
moneyField.setBounds (20, 70, 100, 40);
radio1.setBounds (20, 120, 100, 30);
radio2.setBounds (140, 120, 100, 30);
option.setBounds (20, 170, 100, 30);
add (bSinglePlayer);
add (bMultiPlayer);
add (moneyField);
add (radio1);
add (radio2);
add (option);
background = getImage (getDocumentBase(), "IntroScreenBackground.jpg");
}
public void paint (Graphics g)
{
g.drawImage (background, 0, 0, this);
}
}