Complete JavaFX pricing plans workshop #1
Generated
+10
@@ -0,0 +1,10 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/WS-06-intro-to-javafx.iml" filepath="$PROJECT_DIR$/WS-06-intro-to-javafx.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +1,7 @@
|
||||
package workshop;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Button;
|
||||
|
||||
@@ -8,7 +9,7 @@ public class Controller {
|
||||
@FXML private Label titleLabel;
|
||||
@FXML private Button themeToggle;
|
||||
|
||||
private boolean isDark = true;
|
||||
private boolean isDark = false;
|
||||
|
||||
// TODO: (Optional:For Practice) Create initialize function and use it to set prices during runtime.
|
||||
|
||||
@@ -17,25 +18,41 @@ public class Controller {
|
||||
@FXML
|
||||
private void buyBasic() {
|
||||
// TODO: Call showAlert() with a message indicating the user entered the payment gateway
|
||||
showAlert("Basic plan Selected");
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void buyPro() {
|
||||
// TODO: Call showAlert() with a message indicating the user entered the payment gateway
|
||||
showAlert("Pro plan Selected");
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void buyEnterprise() {
|
||||
// TODO: Call showAlert() with a message indicating the user entered the payment gateway
|
||||
showAlert("Enterprise plan Selected");
|
||||
}
|
||||
|
||||
@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 Mode");
|
||||
}
|
||||
else {
|
||||
themeToggle.getScene().getStylesheets().add(getClass().getResource("light.css").toExternalForm());
|
||||
themeToggle.setText("Switch to Dark Mode");
|
||||
}
|
||||
// TODO: Toggle the isDark flag. If dark, switch to style.css and set button text to "Switch to Light Mode"
|
||||
// TODO: If light, switch to light.css and set button text to "Switch to Dark Mode"
|
||||
}
|
||||
|
||||
private void showAlert(String message) {
|
||||
// TODO: Create a new Alert of type INFORMATION with the given message and display it
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setHeaderText(message);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ import javafx.application.Application;
|
||||
|
||||
public class Launcher {
|
||||
public static void main(String[] args) {
|
||||
// TODO: Launch the JavaFX application by calling Application.launch(Main.class)
|
||||
Application.launch(Main.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package workshop;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class Main extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
// TODO: Load the FXML file using FXMLLoader.load() and get the Parent root
|
||||
// TODO: Create a Scene with the root (width=750, height=450) and add the stylesheet "style.css"
|
||||
// TODO: Set the stage title to "Pricing Plans", set the scene, and call stage.show()
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("pricing.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 750 , 450);
|
||||
scene.getStylesheets().add(getClass().getResource("light.css").toExternalForm());
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Pricing Plans");
|
||||
stage.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox spacing="20" alignment="CENTER" xmlns:fx="http://javafx.com/fxml" fx:controller="workshop.Controller">
|
||||
<VBox spacing="20" alignment="TOP_CENTER" xmlns:fx="http://javafx.com/fxml" fx:controller="workshop.Controller">
|
||||
<padding><Insets top="30" right="30" left="30" bottom="20"/></padding>
|
||||
|
||||
<HBox spacing="10" alignment="CENTER">
|
||||
<Label fx:id="titleLabel" text="Choose Your Plan" styleClass="title" />
|
||||
<Button fx:id="themeToggle" text="Switch to Light Mode" onAction="#toggleTheme" styleClass="toggle-btn" />
|
||||
<Button fx:id="themeToggle" text="Switch to Dark Mode" onAction="#toggleTheme" styleClass="toggle-btn" />
|
||||
</HBox>
|
||||
|
||||
<HBox spacing="25" alignment="CENTER" HBox.hgrow="ALWAYS">
|
||||
|
||||
Reference in New Issue
Block a user