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;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
public class Controller {
@FXML public Label basicPriceLabel;
@FXML public Label ProPriceLabel;
@FXML public Label enterPrisePrice;
@FXML private Label titleLabel;
@FXML private Button themeToggle;
public class Controller
{
@FXML
private Label titleLabel;
@FXML
private Button themeToggle;
private boolean isDark = true;
// (Optional)
@FXML
private void initialize(){
basicPriceLabel.setText("$12.99 / month");
ProPriceLabel.setText("$20.66 / month");
enterPrisePrice.setText("Join us");
}
public void initialize() {}
@FXML
private void buyBasic() {
showAlert("Bacis plan Selected",Alert.AlertType.INFORMATION);
}
private void buyBasic() {showAlert("You entered the payment gateway for the Basic plan.");}
@FXML
private void buyPro() {
showAlert("Pro plan Selected",Alert.AlertType.WARNING);
}
private void buyPro() {showAlert("You entered the payment gateway for the Pro plan.");}
@FXML
private void buyEnterprise() {
showAlert("Enter price Selected",Alert.AlertType.CONFIRMATION);
}
private void buyEnterprise() {showAlert("You entered the payment gateway for the Enterprise plan.");}
@FXML
private void toggleTheme() {
isDark= !isDark;
themeToggle.getScene().getStylesheets().clear();
if(isDark){
themeToggle.getScene().getStylesheets().add(getClass().getResource("style.css").toExternalForm());
themeToggle.setText("Switch to light mood");
private void toggleTheme()
{
Scene scene = themeToggle.getScene();
if (isDark)
{
scene.getStylesheets().clear();
scene.getStylesheets().add(
getClass().getResource("light.css").toExternalForm()
);
themeToggle.setText("Switch to Dark Mode");
isDark = false;
}
else{
themeToggle.getScene().getStylesheets().add(getClass().getResource("light.css").toExternalForm());
themeToggle.setText("Switch to Dark mood");
else
{
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) {
Alert alert = new Alert(alertType);
alert.setHeaderText(msseage);
alert.show();
private void showAlert(String message)
{
Alert alert = new Alert(Alert.AlertType.INFORMATION);
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;
public class Launcher {
public static void main(String[] args) {
Application.launch(Main.class);
}
}
public class Launcher
{
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.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
public class Main extends Application
{
@Override
public void start(Stage stage) throws Exception {
public void start(Stage stage) throws Exception
{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("pricing.fxml"));
Scene scene = new Scene(fxmlLoader.load(),750,450);
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
Parent root = fxmlLoader.load();
Scene scene = new Scene(root, 750, 450);
scene.getStylesheets().add(
getClass().getResource("style.css").toExternalForm()
);
stage.setScene(scene);
stage.setTitle("Pricing Plans");
stage.setScene(scene);
stage.show();
//stage.setResizable(false);
}
}
}
+3 -3
View File
@@ -17,21 +17,21 @@
<HBox spacing="25" alignment="CENTER" HBox.hgrow="ALWAYS">
<VBox styleClass="card" prefWidth="200">
<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" />
<Button text="Shop" onAction="#buyBasic" styleClass="shop-btn" />
</VBox>
<VBox styleClass="card" prefWidth="200">
<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" />
<Button text="Shop" onAction="#buyPro" styleClass="shop-btn" />
</VBox>
<VBox styleClass="card" prefWidth="200">
<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" />
<Button text="Shop" onAction="#buyEnterprise" styleClass="shop-btn" />
</VBox>