aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-04-29 07:51:09 +0200
committerJonas Smedegaard <dr@jones.dk>2025-04-29 07:51:09 +0200
commit794be4694f1a1fa36d87543aab840331c6d39745 (patch)
treefba76f42b40d37889810353828d6eefa3b7b1ff9 /src
parent705b7a5a32793f7ed8a24b8b35afe3f9d49348be (diff)
explicitly define magic numbers
Diffstat (limited to 'src')
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Window.java22
-rw-r--r--src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java19
2 files changed, 31 insertions, 10 deletions
diff --git a/src/com.example.portfolio2/com/example/portfolio2/Window.java b/src/com.example.portfolio2/com/example/portfolio2/Window.java
index 2a92241..6977d6b 100644
--- a/src/com.example.portfolio2/com/example/portfolio2/Window.java
+++ b/src/com.example.portfolio2/com/example/portfolio2/Window.java
@@ -26,8 +26,20 @@ public final class Window extends Application {
// (declared explicitly only to silence javadoc)
public Window() { }
+ /// window width
+ private static final int WINDOW_WIDTH = 1000;
+
+ /// window height
+ private static final int WINDOW_HEIGHT = 500;
+
+ /// box width
+ private static final int LIST_WIDTH = 250;
+
+ /// box height
+ private static final int LIST_HEIGHT = 35;
+
/// Label styling
- public static final String LABEL_STYLE =
+ private static final String LABEL_STYLE =
"-fx-font-weight: bold;-fx-font-size: 18;-fx-padding: 10";
/// Storage model
@@ -56,9 +68,9 @@ public final class Window extends Application {
for (ActivityColumn col : columns) {
col.nameLabel.setStyle(LABEL_STYLE);
col.ectsLabel.setStyle(LABEL_STYLE);
- col.categoryCombo.setPrefSize(250, 35);
- col.activitySelect.setPrefSize(250, 35);
- col.area.setPrefWidth(250);
+ col.categoryCombo.setPrefSize(LIST_WIDTH, LIST_HEIGHT);
+ col.activitySelect.setPrefSize(LIST_WIDTH, LIST_HEIGHT);
+ col.area.setPrefWidth(LIST_WIDTH);
// all boxes share same activity logic
col.activitySelect.setOnAction(event -> {
@@ -102,7 +114,7 @@ public final class Window extends Application {
// define HBox and scene for columns
HBox root = new HBox(columns.get(0).asVBox(), columns.get(1).asVBox(), columns.get(2).asVBox(), columns.get(3).asVBox());
- Scene scene = new Scene(root, 1000, 500);
+ Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT);
stage.setTitle("Course Selector RUC: Ultimate Deluxe Edition");
stage.setScene(scene);
stage.show();
diff --git a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java
index df29ced..d75e05c 100644
--- a/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java
+++ b/src/dk.biks.bachelorizer/dk/biks/bachelorizer/Window.java
@@ -24,8 +24,17 @@ public final class Window extends Application {
public Window() {
}
+ /// window width
+ private static final int WINDOW_WIDTH = 500;
+
+ /// window height
+ private static final int WINDOW_HEIGHT = 500;
+
+ /// box height
+ private static final int BOX_HEIGHT = 10;
+
/// Label styling
- public static String LABEL_STYLE =
+ private static String LABEL_STYLE =
"-fx-font-weight: bold; -fx-font-size: 20;";
/// Application model
@@ -71,14 +80,14 @@ public final class Window extends Application {
delAll.setOnAction(e -> control.delAll());
// add buttons
- VBox root = new VBox(10,
+ VBox root = new VBox(BOX_HEIGHT,
ourHBox("Student", nameEntry),
ourHBox("Add activity", activityEntry),
- new HBox(10, delOne, delAll),
+ new HBox(BOX_HEIGHT, delOne, delAll),
area);
// compose stage
- Scene scene = new Scene(root, 500, 500);
+ Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT);
stage.setTitle("JavaFX Demo");
stage.setScene(scene);
stage.show();
@@ -112,6 +121,6 @@ public final class Window extends Application {
Label label = new Label(s + ":");
label.setStyle(LABEL_STYLE);
- return new HBox(10, label, f);
+ return new HBox(BOX_HEIGHT, label, f);
}
}