finish javafx

This commit is contained in:
2026-05-17 22:19:51 +03:30
parent 54f96e8fb9
commit 30e199fc30
4 changed files with 40 additions and 15 deletions
+25 -8
View File
@@ -1,39 +1,56 @@
package workshop;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
public class Controller {
@FXML public Label basicPriceLabel;
@FXML public Label ProPriceLabel;
@FXML public Label enterPrisePrice;
@FXML private Label titleLabel;
@FXML private Button themeToggle;
private boolean isDark = true;
// TODO: (Optional) Create initialize function and use it to set prices during runtime.
@FXML
private void initialize(){
basicPriceLabel.setText("$12.99 / month");
}
@FXML
private void buyBasic() {
// TODO: Call showAlert() with a message indicating the user entered the payment gateway
showAlert(Alert.AlertType.INFORMATION);
}
@FXML
private void buyPro() {
// TODO: Call showAlert() with a message indicating the user entered the payment gateway
showAlert(Alert.AlertType.WARNING);
}
@FXML
private void buyEnterprise() {
// TODO: Call showAlert() with a message indicating the user entered the payment gateway
showAlert(Alert.AlertType.CONFIRMATION);
}
@FXML
private void toggleTheme() {
// 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"
isDark= !isDark;
themeToggle.getScene().getStylesheets().clear();
if(isDark){
themeToggle.getScene().getStylesheets().add(getClass().getResource("style.css").toExternalForm());
themeToggle.setText("Switch to light mood");
}
else{
themeToggle.getScene().getStylesheets().add(getClass().getResource("light.css").toExternalForm());
themeToggle.setText("Switch to Dark mood");
}
}
private void showAlert(String message) {
// TODO: Create a new Alert of type INFORMATION with the given message and display it
private void showAlert(Alert.AlertType alertType) {
Alert alert = new Alert(alertType);
alert.setHeaderText("Bacis plan Selected");
alert.show();
}
}