2 Commits
Author SHA1 Message Date
reyhne 252b5fe044 Merge pull request 'Pricing Plans UI' (#1) from develop into main
Reviewed-on: Romina/WS-06-intro-to-javafx#1
2026-07-17 17:33:19 +00:00
Romina d6de2e7159 Pricing Plans UI 2026-07-17 16:38:29 +03:30
4 changed files with 65 additions and 50 deletions
+45 -35
View File
@@ -1,58 +1,68 @@
package workshop; package workshop;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label;
public class Controller { public class Controller
@FXML public Label basicPriceLabel; {
@FXML public Label ProPriceLabel; @FXML
@FXML public Label enterPrisePrice; private Label titleLabel;
@FXML private Label titleLabel;
@FXML private Button themeToggle; @FXML
private Button themeToggle;
private boolean isDark = true; private boolean isDark = true;
// (Optional)
@FXML @FXML
private void initialize(){ public void initialize() {}
basicPriceLabel.setText("$12.99 / month");
ProPriceLabel.setText("$20.66 / month");
enterPrisePrice.setText("Join us");
}
@FXML @FXML
private void buyBasic() { private void buyBasic() {showAlert("You entered the payment gateway for the Basic plan.");}
showAlert("Bacis plan Selected",Alert.AlertType.INFORMATION);
}
@FXML @FXML
private void buyPro() { private void buyPro() {showAlert("You entered the payment gateway for the Pro plan.");}
showAlert("Pro plan Selected",Alert.AlertType.WARNING);
}
@FXML @FXML
private void buyEnterprise() { private void buyEnterprise() {showAlert("You entered the payment gateway for the Enterprise plan.");}
showAlert("Enter price Selected",Alert.AlertType.CONFIRMATION);
}
@FXML @FXML
private void toggleTheme() { private void toggleTheme()
isDark= !isDark; {
themeToggle.getScene().getStylesheets().clear(); Scene scene = themeToggle.getScene();
if(isDark){
themeToggle.getScene().getStylesheets().add(getClass().getResource("style.css").toExternalForm()); if (isDark)
themeToggle.setText("Switch to light mood"); {
scene.getStylesheets().clear();
scene.getStylesheets().add(
getClass().getResource("light.css").toExternalForm()
);
themeToggle.setText("Switch to Dark Mode");
isDark = false;
} }
else{ else
themeToggle.getScene().getStylesheets().add(getClass().getResource("light.css").toExternalForm()); {
themeToggle.setText("Switch to Dark mood"); scene.getStylesheets().clear();
scene.getStylesheets().add(
getClass().getResource("style.css").toExternalForm()
);
themeToggle.setText("Switch to Light Mode");
isDark = true;
} }
} }
private void showAlert(String msseage, Alert.AlertType alertType) { private void showAlert(String message)
Alert alert = new Alert(alertType); {
alert.setHeaderText(msseage); Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.show(); alert.setTitle("Payment");
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
} }
} }
+4 -5
View File
@@ -2,8 +2,7 @@ package workshop;
import javafx.application.Application; import javafx.application.Application;
public class Launcher { public class Launcher
public static void main(String[] args) { {
Application.launch(Main.class); public static void main(String[] args) {Application.launch(Main.class, args);}
} }
}
+13 -7
View File
@@ -2,20 +2,26 @@ package workshop;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
public class Main extends Application { public class Main extends Application
{
@Override @Override
public void start(Stage stage) throws Exception { public void start(Stage stage) throws Exception
{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("pricing.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("pricing.fxml"));
Scene scene = new Scene(fxmlLoader.load(),750,450); Parent root = fxmlLoader.load();
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
Scene scene = new Scene(root, 750, 450);
scene.getStylesheets().add(
getClass().getResource("style.css").toExternalForm()
);
stage.setScene(scene);
stage.setTitle("Pricing Plans"); stage.setTitle("Pricing Plans");
stage.setScene(scene);
stage.show(); stage.show();
//stage.setResizable(false);
} }
} }
+3 -3
View File
@@ -17,21 +17,21 @@
<HBox spacing="25" alignment="CENTER" HBox.hgrow="ALWAYS"> <HBox spacing="25" alignment="CENTER" HBox.hgrow="ALWAYS">
<VBox styleClass="card" prefWidth="200"> <VBox styleClass="card" prefWidth="200">
<Label text="Basic" styleClass="plan-name" /> <Label text="Basic" styleClass="plan-name" />
<Label fx:id="basicPriceLabel" text="/$9.99 / month" styleClass="price" /> <Label text="\$9.99 / month" styleClass="price" />
<Label text="Single user, basic features" styleClass="desc" wrapText="true" /> <Label text="Single user, basic features" styleClass="desc" wrapText="true" />
<Button text="Shop" onAction="#buyBasic" styleClass="shop-btn" /> <Button text="Shop" onAction="#buyBasic" styleClass="shop-btn" />
</VBox> </VBox>
<VBox styleClass="card" prefWidth="200"> <VBox styleClass="card" prefWidth="200">
<Label text="Pro" styleClass="plan-name" /> <Label text="Pro" styleClass="plan-name" />
<Label fx:id="ProPriceLabel" text="/$19.99 / month" styleClass="price" /> <Label text="\$19.99 / month" styleClass="price" />
<Label text="Up to 5 users, advanced features" styleClass="desc" wrapText="true" /> <Label text="Up to 5 users, advanced features" styleClass="desc" wrapText="true" />
<Button text="Shop" onAction="#buyPro" styleClass="shop-btn" /> <Button text="Shop" onAction="#buyPro" styleClass="shop-btn" />
</VBox> </VBox>
<VBox styleClass="card" prefWidth="200"> <VBox styleClass="card" prefWidth="200">
<Label text="Enterprise" styleClass="plan-name" /> <Label text="Enterprise" styleClass="plan-name" />
<Label fx:id="enterPrisePrice" text="Contact us" styleClass="price" /> <Label text="Contact us" styleClass="price" />
<Label text="Unlimited users, custom solutions" styleClass="desc" wrapText="true" /> <Label text="Unlimited users, custom solutions" styleClass="desc" wrapText="true" />
<Button text="Shop" onAction="#buyEnterprise" styleClass="shop-btn" /> <Button text="Shop" onAction="#buyEnterprise" styleClass="shop-btn" />
</VBox> </VBox>