本文整理汇总了Java中javafx.scene.control.DialogEvent类的典型用法代码示例。如果您正苦于以下问题:Java DialogEvent类的具体用法?Java DialogEvent怎么用?Java DialogEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DialogEvent类属于javafx.scene.control包,在下文中一共展示了DialogEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TemplateBox
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public TemplateBox(String name) {
setTitle(name);
initModality(Modality.NONE);
String style = LocalFont.getDefaultFontCSS();
getDialogPane().setStyle(
style
);
Stage stage = (Stage) getDialogPane().getScene().getWindow();
stage.setAlwaysOnTop(checkForceOnTop());
stage.getIcons().add(new Image(App.ICON_URL.toString()));
getDialogPane().getButtonTypes().add(new ButtonType(Main.getString("close"), ButtonBar.ButtonData.CANCEL_CLOSE));
openedDialogs.add(this);
final TemplateBox thisBox = this;
setOnCloseRequest(new EventHandler<DialogEvent>() {
@Override
public void handle(DialogEvent event) {
openedDialogs.remove(thisBox);
for(EventHandler<DialogEvent> handler : handlers){
handler.handle(event);
}
}
});
applyStyle();
}
示例2: prepareDialog
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
/**
* Initialize a dialog by setting its title, header and content
* and set window style to "utility dialog".
*
* @param dialog The dialog to initialize
* @param keyTitle Key for dialog title in the translation file
* @param keyHeader Key for dialog header in the translation file
* @param keyContent Key for dialog content in the translation file
* @param windowData The position and size of the parent window
*/
protected static void prepareDialog(final Dialog dialog, final String keyTitle,
final String keyHeader, final String keyContent, final ParentWindowData windowData) {
dialog.setTitle(TRANSLATIONS.getString(keyTitle));
dialog.setHeaderText(TRANSLATIONS.getString(keyHeader));
dialog.setContentText(TRANSLATIONS.getString(keyContent));
((Stage) dialog.getDialogPane().getScene().getWindow()).initStyle(StageStyle.UTILITY);
dialog.setResizable(false);
/* Handler to place the dialog in the middle of the main window instead of the middle
* of the screen; the width oh the dialog is fixed. */
dialog.setOnShown(new EventHandler<DialogEvent>() {
public void handle(final DialogEvent event) {
dialog.setWidth(DIALOG_WIDTH);
dialog.getDialogPane().setMaxWidth(DIALOG_WIDTH);
dialog.getDialogPane().setMinWidth(DIALOG_WIDTH);
dialog.setX(windowData.getX() + (windowData.getWidth() / 2) - (dialog.getWidth() / 2));
dialog.setY(windowData.getY() + 30);
}
});
}
示例3: end
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
/**
* Method to be called on song end
* @param lastReport last GameReport
*/
private void end(GameReport lastReport) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Clone Hero");
alert.setHeaderText("You've completed this song!");
alert.setContentText("Your score: " + lastReport.getScore());
alert.setOnCloseRequest(new EventHandler<DialogEvent>() {
@Override
public void handle(DialogEvent event) {
stage.hide();
}
});
alert.show();
}
示例4: addOnCloseRequest
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public void addOnCloseRequest(EventHandler<DialogEvent> handler){
handlers.add(handler);
}
示例5: resetFromModel
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
private void resetFromModel(@SuppressWarnings("UnusedParameters") final DialogEvent dialogEvent) {
pendingSelectedZoneIds.setValue(observableSet(applicationModel.selectedZoneIds.toArray(new
ZoneId[applicationModel.selectedZoneIds.size()])));
zoneIdCheckboxes.stream().forEach(zoneIdCheckBox -> zoneIdCheckBox.setSelected(pendingSelectedZoneIds
.contains(ZoneId.of(zoneIdCheckBox.getText()))));
}
示例6: JFXAlert
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public JFXAlert(Stage stage) {
// set the stage to transparent
initStyle(StageStyle.TRANSPARENT);
initOwner(stage);
// create custom dialog pane
setDialogPane(new DialogPane() {
{
getButtonTypes().add(ButtonType.CLOSE);
Node closeButton = this.lookupButton(ButtonType.CLOSE);
closeButton.managedProperty().bind(closeButton.visibleProperty());
closeButton.setVisible(false);
}
@Override
protected Node createButtonBar() {
return null;
}
});
// init style for the content container
contentContainer = new StackPane();
contentContainer.getStyleClass().add("jfx-alert-content-container");
// set dialog pane content
final Node materialNode = JFXDepthManager.createMaterialNode(contentContainer, 2);
materialNode.setPickOnBounds(false);
materialNode.addEventHandler(MouseEvent.MOUSE_CLICKED, event->event.consume());
// init style for overlay
overlay = new StackPane(materialNode){
public String getUserAgentStylesheet() {
return getClass().getResource("/css/controls/jfx-alert.css").toExternalForm();
}
};
overlay.getStyleClass().add("jfx-alert-overlay");
// customize dialogPane
final DialogPane dialogPane = getDialogPane();
dialogPane.getScene().setFill(Color.TRANSPARENT);
dialogPane.setStyle("-fx-background-color: transparent;");
dialogPane.prefWidthProperty().bind(stage.getScene().widthProperty());
dialogPane.prefHeightProperty().bind(stage.getScene().heightProperty());
dialogPane.setContent(overlay);
updateX(stage, dialogPane);
updateY(stage, dialogPane);
// bind dialog position to stage position
stage.getScene().widthProperty().addListener(observable -> updateSize(dialogPane));
stage.getScene().heightProperty().addListener(observable -> updateSize(dialogPane));
stage.xProperty().addListener((observable, oldValue, newValue) -> updateX(stage, dialogPane));
stage.yProperty().addListener((observable, oldValue, newValue) -> updateY(stage, dialogPane));
// handle animation
eventHandlerManager.addEventHandler(DialogEvent.DIALOG_SHOWING, event -> {
if (getAnimation() != null) {
getAnimation().initAnimation(contentContainer.getParent(), overlay);
}
});
eventHandlerManager.addEventHandler(DialogEvent.DIALOG_SHOWN, event -> {
if (getAnimation() != null) {
Animation animation = getAnimation().createShowingAnimation(contentContainer.getParent(), overlay);
if (animation != null) {
animation.play();
}
}
});
overlay.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
if (this.isOverlayClose()) {
new Thread(() -> hideWithAnimation()).start();
}
});
}
示例7: friendly_setOnCloseRequest
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
/**
* {@link Alert#setOnCloseRequest(EventHandler)}.
* @param handler the {@link EventHandler}.
*/
public void friendly_setOnCloseRequest( EventHandler< DialogEvent > handler ) {
setOnCloseRequest( handler );
}
示例8: setOnShowing
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final void setOnShowing(EventHandler<DialogEvent> handler) { dialog.setOnShowing(handler);}
示例9: getOnShowing
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final EventHandler<DialogEvent> getOnShowing() { return dialog.getOnShowing(); }
示例10: setOnShown
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final void setOnShown(EventHandler<DialogEvent> handler) { dialog.setOnShown(handler);}
示例11: getOnShown
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final EventHandler<DialogEvent> getOnShown() { return dialog.getOnShown(); }
示例12: setOnCloseRequest
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final void setOnCloseRequest(EventHandler<DialogEvent> handler) {dialog.setOnCloseRequest(handler);}
示例13: getOnCloseRequest
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final EventHandler<DialogEvent> getOnCloseRequest() { return dialog.getOnCloseRequest(); }
示例14: setOnHiding
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final void setOnHiding(EventHandler<DialogEvent> handler) { dialog.setOnHiding(handler);}
示例15: getOnHiding
import javafx.scene.control.DialogEvent; //导入依赖的package包/类
public final EventHandler<DialogEvent> getOnHiding() { return dialog.getOnHiding(); }