-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment6.java
More file actions
174 lines (153 loc) · 6.95 KB
/
Copy pathAssignment6.java
File metadata and controls
174 lines (153 loc) · 6.95 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package Assignment6;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Stage;
import javafx.scene.control.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class Assignment6 extends Application {
private class ButtonHandler implements EventHandler<ActionEvent> {
@Override
public void handle (ActionEvent actionEvent){
if(actionEvent.getTarget() == submitButton){
System.out.println(firstName.getText() + " " + lastName.getText());
RadioButton temp = (RadioButton) pizzaSize.getSelectedToggle();
System.out.println("Ordered a " + temp.getText() + " " + pizzaType.getValue() + "\nwith toppings:");
if(rainbows.isSelected()){
System.out.println(rainbows.getText() + ", ");
}
if(stars.isSelected()){
System.out.print(stars.getText() + ", ");
}
if(horseshoes.isSelected()){
System.out.print(horseshoes.getText() + ", ");
}
if(hearts.isSelected()){
System.out.print(hearts.getText() + ", ");
}
if(clovers.isSelected()){
System.out.print(clovers.getText() + ", ");
}
if(redBalloons.isSelected()){
System.out.print(redBalloons.getText());
}
System.out.println("\nand comments:");
System.out.println(comments.getText());
}
}
}
private Scene scene;
private Label welcomeMessage;
private ImageView logo;
private ComboBox<String> pizzaType;
private ToggleGroup pizzaSize;
private RadioButton small, medium, large;
private CheckBox rainbows, stars, horseshoes, hearts, clovers, redBalloons;
private TextField firstName, lastName;
private TextArea comments;
private Button submitButton;
@Override
public void start(Stage primaryStage) {
Font boldFont = Font.font("System", FontWeight.BOLD, 32.0);
Font labelFont = Font.font("System", FontWeight.BOLD, 14.0);
welcomeMessage = new Label("Welcome to PizzaLand!");
welcomeMessage.setFont(boldFont);
Image logoImage;
try {
// Provide the path to your image file
FileInputStream inputStream = new FileInputStream("J:\\2430 OOP\\IDEA\\InclassActivities\\JavaFxProject\\src\\Assignment6\\pizzalandlogo.png");
logoImage = new Image(inputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
return;
}
logo = new ImageView(logoImage);
logo.setPreserveRatio(true);
logo.setFitWidth(300);
Label pizzaTypeLabel = new Label("Pizza Type");
pizzaTypeLabel.setFont(labelFont);
pizzaType = new ComboBox<>();
pizzaType.getItems().addAll("Plain", "Seafood", "Vegetarian", "Bacon", "Hawaiian", "Uni's Electric Rainbow Signature Pizza");
Label pizzaSizeLabel = new Label("Pizza Size");
pizzaSizeLabel.setFont(labelFont);
pizzaSize = new ToggleGroup();
small = new RadioButton("Small");
small.setToggleGroup(pizzaSize);
small.setPadding(new Insets(0, 8, 0, 0));
medium = new RadioButton("Medium");
medium.setToggleGroup(pizzaSize);
large = new RadioButton("Large");
large.setToggleGroup(pizzaSize);
large.setPadding(new Insets(0, 7, 0, 0));
Label toppingsLabel = new Label("Toppings");
toppingsLabel.setFont(labelFont);
rainbows = new CheckBox("Rainbows");
rainbows.setPadding(new Insets(0, 5, 0, 0));
stars = new CheckBox("stars");
stars.setPadding(new Insets(0, 18, 0, 0));
horseshoes = new CheckBox("Horseshoes");
hearts = new CheckBox("Hearts");
hearts.setPadding(new Insets(0, 17, 0, 0));
clovers = new CheckBox("Clovers");
clovers.setPadding(new Insets(0, 15, 0, 0));
redBalloons = new CheckBox("Red Balloons");
Label firstNameLabel = new Label("First Name");
firstNameLabel.setFont(labelFont);
firstName = new TextField();
Label lastNameLabel = new Label("Last Name");
lastNameLabel.setFont(labelFont);
lastName = new TextField();
Label commentsLabel = new Label("Comments");
commentsLabel.setFont(labelFont);
comments = new TextArea();
ButtonHandler buttonHandler = new ButtonHandler();
submitButton = new Button("Submit");
submitButton.setOnAction(buttonHandler);
VBox mainPane = new VBox();
VBox titleLogo = new VBox();
titleLogo.getChildren().addAll(welcomeMessage, logo);
mainPane.getChildren().add(titleLogo);
VBox inputFields = new VBox();
HBox pizzaTypeHBox = new HBox();
GridPane inputs = new GridPane();
pizzaTypeHBox.getChildren().addAll(pizzaTypeLabel, pizzaType);
inputFields.getChildren().add(pizzaTypeHBox);
VBox pizzaSizeVBox = new VBox();
pizzaSizeVBox.getChildren().addAll(pizzaSizeLabel, small, medium, large);
inputs.add(pizzaSizeVBox,0,0);
VBox toppingsVBox = new VBox();
HBox toppingsRowOne = new HBox();
toppingsRowOne.getChildren().addAll(rainbows,hearts);
HBox toppingsRowTwo = new HBox();
toppingsRowTwo.getChildren().addAll(stars,clovers);
HBox toppingsRowThree = new HBox();
toppingsRowThree.getChildren().addAll(horseshoes,redBalloons);
toppingsVBox.getChildren().addAll(toppingsRowOne,toppingsRowTwo,toppingsRowThree);
inputs.add(toppingsVBox,1, 0);
VBox customerInformation = new VBox();
HBox firstNameHBox = new HBox();
firstNameHBox.getChildren().addAll(firstNameLabel,firstName);
HBox lastNameHBox = new HBox();
lastNameHBox.getChildren().addAll(lastNameLabel, lastName);
customerInformation.getChildren().addAll(firstNameHBox,lastNameHBox);
inputs.add(customerInformation, 0, 1);
VBox commentsVBox = new VBox();
commentsVBox.getChildren().addAll(commentsLabel, comments);
inputs.add(commentsVBox,1, 1);
inputFields.getChildren().add(inputs);
mainPane.getChildren().add(inputFields);
mainPane.getChildren().add(submitButton);
scene = new Scene(mainPane);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.setTitle("Student Registration Form");
primaryStage.show();
}
}