Skip to content

Commit 56698f3

Browse files
committed
Made prettier with css file. added some final comments
1 parent e51cbd7 commit 56698f3

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

src/main/java/org/example/csc311_mod6regex/RegexApplication.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
public class RegexApplication extends Application {
1111
@Override
1212
public void start(Stage stage) throws IOException {
13-
FXMLLoader fxmlLoader = new FXMLLoader(RegexApplication.class.getResource("hello-view.fxml"));
14-
Scene scene = new Scene(fxmlLoader.load(), 600, 400);
15-
stage.setTitle("Hello!");
13+
FXMLLoader fxmlLoader = new FXMLLoader(RegexApplication.class.getResource("regex-app-view.fxml"));
14+
Scene scene = new Scene(fxmlLoader.load(), 650, 400);
15+
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
16+
stage.setTitle("Fill out this form!");
1617
stage.setScene(scene);
1718
stage.show();
1819
}

src/main/java/org/example/csc311_mod6regex/RegexController.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class RegexController {
3131
@FXML
3232
private Label zipCodeErrorLabel;
3333
@FXML
34+
private Label successLabel;
35+
@FXML
3436
private Button addBtn;
3537

3638
private Pattern firstnameRegex;
@@ -52,11 +54,17 @@ public class RegexController {
5254
*/
5355
@FXML
5456
public void initialize() {
57+
//both name patterns check for starting upper case character and allow for apostrophes!
58+
firstnameRegex = Pattern.compile("^[A-Za-z||']{2,25}$");
59+
lastNameRegex = Pattern.compile("^[A-Za-z||']{2,25}$");
5560

56-
firstnameRegex = Pattern.compile("^[A-Za-z]{2,25}$");
57-
lastNameRegex = Pattern.compile("^[A-Za-z]{2,25}$");
61+
//email pattern doesnt allow for numbers to start and end in farmingdale.edu
5862
emailRegex = Pattern.compile("^[A-Za-z0-9._%+-]+@farmingdale\\.edu$");
63+
64+
//can only be MM/DD/YYYY
5965
dateOfBirthRegex = Pattern.compile("^\\d{2}/\\d{2}/\\d{4}$");
66+
67+
//only 5 digit zipcodes
6068
zipCodeRegex = Pattern.compile("^\\d{5}$");
6169

6270
formManager();
@@ -66,7 +74,7 @@ public void initialize() {
6674
}
6775

6876
/**
69-
* this method handles the event of clicking the addBtn.
77+
* This method handles the event of clicking the addBtn.
7078
* @param event The clicking of addBtn
7179
*/
7280
@FXML
@@ -75,6 +83,7 @@ private void handleAddBtn(ActionEvent event) {
7583
System.out.println("Add button clicked");
7684
if (formCheck && fieldFilledCount >= 4) {
7785
System.out.println("Form Filled");
86+
successLabel.setText("Form Filled");
7887
}
7988

8089
}

src/main/resources/org/example/csc311_mod6regex/hello-view.fxml renamed to src/main/resources/org/example/csc311_mod6regex/regex-app-view.fxml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<?import javafx.scene.control.Button?>
55
<?import javafx.scene.control.Label?>
66
<?import javafx.scene.control.TextField?>
7+
<?import javafx.scene.image.ImageView?>
78
<?import javafx.scene.layout.HBox?>
89
<?import javafx.scene.layout.Pane?>
910
<?import javafx.scene.layout.VBox?>
@@ -149,6 +150,16 @@
149150
</HBox.margin>
150151
<children>
151152
<Button fx:id="addBtn" layoutX="-82.0" layoutY="182.0" mnemonicParsing="false" onAction="#handleAddBtn" prefHeight="37.0" prefWidth="127.0" text="ADD" />
153+
<!-- <ImageView fitHeight="133.0" fitWidth="139.0" layoutX="-88.0" layoutY="28.0" pickOnBounds="true" preserveRatio="true">-->
154+
<!-- <image>-->
155+
<!--&lt;!&ndash; <Image url="@images/thumbs-up-icon-31142.png" />&ndash;&gt;-->
156+
<!-- </image>-->
157+
<!-- </ImageView>-->
158+
<Label fx:id="successLabel" alignment="CENTER" layoutX="-81.0" layoutY="227.0" prefHeight="17.0" prefWidth="127.0">
159+
<font>
160+
<Font name="Book Antiqua" size="18.0" />
161+
</font>
162+
</Label>
152163
</children>
153164
</Pane>
154165
</children>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.root {
2+
-fx-background-color: #f0f4f8;
3+
-fx-font-family: 'Segoe UI', sans-serif;
4+
}
5+
6+
/* Base button style */
7+
.button {
8+
-fx-background-color: linear-gradient(to bottom right, #4a90e2, #357ABD);
9+
-fx-text-fill: white;
10+
-fx-font-size: 14px;
11+
-fx-font-weight: bold;
12+
-fx-padding: 10 20 10 20;
13+
-fx-background-radius: 10;
14+
-fx-cursor: hand;
15+
-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.2), 8, 0, 0, 4);
16+
-fx-border-width: 0;
17+
-fx-transition: all 0.3s ease-in-out;
18+
}
19+
20+
/* Hover effect */
21+
.button:hover {
22+
-fx-background-color: linear-gradient(to bottom right, #5aa0f0, #3f85d0);
23+
-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.3), 10, 0, 0, 6);
24+
}
25+
26+
/* Click effect */
27+
.button:pressed {
28+
-fx-translate-y: 2px;
29+
-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.15), 6, 0, 0, 2);
30+
}

0 commit comments

Comments
 (0)