Apply customized Sampler styles before showing a modal dialog #46
This commit is contained in:
parent
7fceac13b0
commit
e5ddb9004f
@ -16,6 +16,7 @@ import javafx.scene.control.Alert;
|
|||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ButtonType;
|
import javafx.scene.control.ButtonType;
|
||||||
import javafx.scene.control.ChoiceDialog;
|
import javafx.scene.control.ChoiceDialog;
|
||||||
|
import javafx.scene.control.Dialog;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextArea;
|
import javafx.scene.control.TextArea;
|
||||||
import javafx.scene.control.TextInputDialog;
|
import javafx.scene.control.TextInputDialog;
|
||||||
@ -59,7 +60,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
alert.setHeaderText(FAKER.chuckNorris().fact());
|
alert.setHeaderText(FAKER.chuckNorris().fact());
|
||||||
alert.setContentText(FAKER.lorem().paragraph(3));
|
alert.setContentText(FAKER.lorem().paragraph(3));
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
|
|
||||||
var warnBtn = new Button("Click", new FontIcon(Feather.ALERT_TRIANGLE));
|
var warnBtn = new Button("Click", new FontIcon(Feather.ALERT_TRIANGLE));
|
||||||
@ -69,7 +70,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
alert.setHeaderText(FAKER.chuckNorris().fact());
|
alert.setHeaderText(FAKER.chuckNorris().fact());
|
||||||
alert.setContentText(FAKER.lorem().paragraph(3));
|
alert.setContentText(FAKER.lorem().paragraph(3));
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
|
|
||||||
var errorBtn = new Button("Click", new FontIcon(Feather.X_CIRCLE));
|
var errorBtn = new Button("Click", new FontIcon(Feather.X_CIRCLE));
|
||||||
@ -79,7 +80,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
alert.setHeaderText(FAKER.chuckNorris().fact());
|
alert.setHeaderText(FAKER.chuckNorris().fact());
|
||||||
alert.setContentText(FAKER.lorem().paragraph(3));
|
alert.setContentText(FAKER.lorem().paragraph(3));
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
//snippet_1:end
|
//snippet_1:end
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
|
|
||||||
alert.getDialogPane().setExpandableContent(content);
|
alert.getDialogPane().setExpandableContent(content);
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
//snippet_2:end
|
//snippet_2:end
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
|
|
||||||
alert.getButtonTypes().setAll(yesBtn, noBtn, cancelBtn);
|
alert.getButtonTypes().setAll(yesBtn, noBtn, cancelBtn);
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
//snippet_3:end
|
//snippet_3:end
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
dialog.setHeaderText(FAKER.chuckNorris().fact());
|
dialog.setHeaderText(FAKER.chuckNorris().fact());
|
||||||
dialog.setContentText("Enter your name:");
|
dialog.setContentText("Enter your name:");
|
||||||
dialog.initOwner(getScene().getWindow());
|
dialog.initOwner(getScene().getWindow());
|
||||||
dialog.showAndWait();
|
show(dialog);
|
||||||
});
|
});
|
||||||
//snippet_4:end
|
//snippet_4:end
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
dialog.setHeaderText(FAKER.chuckNorris().fact());
|
dialog.setHeaderText(FAKER.chuckNorris().fact());
|
||||||
dialog.setContentText("Choose your letter:");
|
dialog.setContentText("Choose your letter:");
|
||||||
dialog.initOwner(getScene().getWindow());
|
dialog.initOwner(getScene().getWindow());
|
||||||
dialog.showAndWait();
|
show(dialog);
|
||||||
});
|
});
|
||||||
//snippet_5:end
|
//snippet_5:end
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
alert.setHeaderText(null);
|
alert.setHeaderText(null);
|
||||||
alert.setContentText(FAKER.lorem().paragraph(3));
|
alert.setContentText(FAKER.lorem().paragraph(3));
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
|
|
||||||
var warnBtn = new Button("Click", new FontIcon(Feather.ALERT_TRIANGLE));
|
var warnBtn = new Button("Click", new FontIcon(Feather.ALERT_TRIANGLE));
|
||||||
@ -239,7 +240,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
alert.setHeaderText(null);
|
alert.setHeaderText(null);
|
||||||
alert.setContentText(FAKER.lorem().paragraph(3));
|
alert.setContentText(FAKER.lorem().paragraph(3));
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
|
|
||||||
var errorBtn = new Button("Click", new FontIcon(Feather.X_CIRCLE));
|
var errorBtn = new Button("Click", new FontIcon(Feather.X_CIRCLE));
|
||||||
@ -249,7 +250,7 @@ public final class DialogPage extends OutlinePage {
|
|||||||
alert.setHeaderText(null);
|
alert.setHeaderText(null);
|
||||||
alert.setContentText(FAKER.lorem().paragraph(3));
|
alert.setContentText(FAKER.lorem().paragraph(3));
|
||||||
alert.initOwner(getScene().getWindow());
|
alert.initOwner(getScene().getWindow());
|
||||||
alert.showAndWait();
|
show(alert);
|
||||||
});
|
});
|
||||||
//snippet_6:end
|
//snippet_6:end
|
||||||
|
|
||||||
@ -263,4 +264,18 @@ public final class DialogPage extends OutlinePage {
|
|||||||
|
|
||||||
return example;
|
return example;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void show(Dialog<?> alert) {
|
||||||
|
// copy customized styles, like changed accent color etc
|
||||||
|
try {
|
||||||
|
for (var pc : getScene().getRoot().getPseudoClassStates()) {
|
||||||
|
alert.getDialogPane().pseudoClassStateChanged(pc, true);
|
||||||
|
}
|
||||||
|
alert.getDialogPane().getStylesheets().addAll(getScene().getRoot().getStylesheets());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// yes, ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user