本文整理汇总了Java中javafx.stage.Window类的典型用法代码示例。如果您正苦于以下问题:Java Window类的具体用法?Java Window怎么用?Java Window使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Window类属于javafx.stage包,在下文中一共展示了Window类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectForJoinTwoPrawnFiles
import javafx.stage.Window; //导入依赖的package包/类
public static List<File> selectForJoinTwoPrawnFiles(Window ownerWindow)
throws IOException, JAXBException, SAXException {
List<File> retVal = new ArrayList<>();
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select Two Prawn XML files");
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Prawn XML files", "*.xml"));
File initDirectory = new File(squidPersistentState.getMRUPrawnFileFolderPath());
fileChooser.setInitialDirectory(initDirectory.exists() ? initDirectory : null);
List<File> prawnXMLFilesNew = fileChooser.showOpenMultipleDialog(ownerWindow);
if (prawnXMLFilesNew != null) {
if ((prawnXMLFilesNew.size() == 2)
&& prawnXMLFilesNew.get(0).getName().toLowerCase(Locale.US).endsWith(".xml")
&& prawnXMLFilesNew.get(1).getName().toLowerCase(Locale.US).endsWith(".xml")) {
retVal = prawnXMLFilesNew;
} else {
throw new IOException("Please choose exactly 2 Prawn xml files to merge.");
}
}
return retVal;
}
示例2: CloseButton
import javafx.stage.Window; //导入依赖的package包/类
public CloseButton (String btnText) {
super(btnText);
setId("closebtn");
setOnAction(e ->
{
debug.Debugger.out("closing button");
Window window = this.getScene().getWindow();
if (myController != null) {
GameModel gm = (GameModel) myController.getModel("game");
if (gm != null) gm.dispose();
}
if (window instanceof Stage){
((Stage) window).close();
} else {
Logger.out("no stage found for closing button");
}
});
}
示例3: DataImportDialog
import javafx.stage.Window; //导入依赖的package包/类
public DataImportDialog(Window owner, FinancialMarket fm, TatConfig config) {
super();
this.fm = fm;
this.config = config;
setResizable(false);
initStyle(StageStyle.DECORATED);
initOwner(owner);
setTitle("Financial Market Import");
initModality(Modality.APPLICATION_MODAL);
Image appIcon = new Image("icon/IMPORT_MARKET_DATA.png");
getIcons().add(appIcon);
root = new Group();
Scene scene = new Scene(root, 500, 440, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk5.jpg"));
scene.setFill(pattern);
setScene(scene);
initGui();
//Add listener to exit when press Esc key
addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
if (KeyCode.ESCAPE == event.getCode()) {
DataImportDialog.this.close();
}
if (KeyCode.ENTER == event.getCode()) {
doImport();
}
});
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例4: selectPrawnFile
import javafx.stage.Window; //导入依赖的package包/类
public static File selectPrawnFile(Window ownerWindow)
throws IOException, JAXBException, SAXException {
File retVal = null;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select Prawn XML file");
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Prawn XML files", "*.xml"));
File initDirectory = new File(squidPersistentState.getMRUPrawnFileFolderPath());
fileChooser.setInitialDirectory(initDirectory.exists() ? initDirectory : null);
File prawnXMLFileNew = fileChooser.showOpenDialog(ownerWindow);
if (prawnXMLFileNew != null) {
if (prawnXMLFileNew.getName().toLowerCase(Locale.US).endsWith(".xml")) {
retVal = prawnXMLFileNew;
} else {
throw new IOException("Filename does not end with '.xml'");
}
}
return retVal;
}
示例5: savePrawnFile
import javafx.stage.Window; //导入依赖的package包/类
public static File savePrawnFile(SquidProject squidProject, Window ownerWindow)
throws IOException, JAXBException, SAXException {
File retVal = null;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Prawn XML file");
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Prawn XML files", "*.xml"));
fileChooser.setInitialDirectory(squidProject.getPrawnFileHandler().currentPrawnFileLocationFolder());
fileChooser.setInitialFileName(squidProject.getPrawnXMLFileName().toUpperCase(Locale.US).replace(".XML", "-REV.xml"));
File prawnXMLFileNew = fileChooser.showSaveDialog(ownerWindow);
if (prawnXMLFileNew != null) {
squidProject.savePrawnFile(prawnXMLFileNew);
retVal = prawnXMLFileNew;
}
return retVal;
}
示例6: saveExpressionFileXML
import javafx.stage.Window; //导入依赖的package包/类
public static File saveExpressionFileXML(Expression expression, Window ownerWindow)
throws IOException {
File retVal = null;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Expression '.xml' file");
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression '.xml' files", "*.xml"));
File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);
fileChooser.setInitialFileName(expression.getName() + ".xml");
File expressionFileXML = fileChooser.showSaveDialog(ownerWindow);
if (expressionFileXML != null) {
retVal = expressionFileXML;
squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
((XMLSerializerInterface) expression)
.serializeXMLObject(expressionFileXML.getAbsolutePath());
}
return retVal;
}
示例7: selectExpressionXMLFile
import javafx.stage.Window; //导入依赖的package包/类
public static File selectExpressionXMLFile(Window ownerWindow)
throws IOException, JAXBException, SAXException {
File retVal = null;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select Expression xml File '.xml");
fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression xml Files", "*.xml"));
File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);
File expressionFileXML = fileChooser.showOpenDialog(ownerWindow);
if (expressionFileXML != null) {
if (expressionFileXML.getName().toLowerCase(Locale.US).endsWith(".xml")) {
squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
retVal = expressionFileXML;
} else {
throw new IOException("Filename does not end with '.xml'");
}
}
return retVal;
}
示例8: generateFileAction
import javafx.stage.Window; //导入依赖的package包/类
@FXML
public void generateFileAction(ActionEvent actionEvent) {
FileChooser saveChooser = new FileChooser();
Window stage = ((Node) actionEvent.getSource()).getScene().getWindow();
saveChooser.setTitle("Zapisz plik");
saveChooser.setInitialDirectory(new File(System.getProperty("user.home")));
saveChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("PDF file", "*.pdf"));
saveChooser.setInitialFileName("faktura.pdf");
File file = saveChooser.showSaveDialog(stage);
if (file != null) {
try {
updateData();
model.setInvoiceData(invoiceData);
model.setReceiverData(receiverData);
model.setSenderData(senderData);
model.generatePDF(file);
} catch (IOException | DocumentException e) {
Dialog dialog = new Dialog<>();
dialog.getDialogPane().getButtonTypes().add(new ButtonType("Ok", ButtonBar.ButtonData.OK_DONE));
dialog.setContentText("Wystąpił błąd podczas próby zapisu");
dialog.showAndWait();
}
}
}
示例9: show
import javafx.stage.Window; //导入依赖的package包/类
@Override
@FXThread
public void show(@NotNull final Window owner) {
super.show(owner);
final EditorConfig editorConfig = EditorConfig.getInstance();
final Path currentAsset = notNull(editorConfig.getCurrentAsset());
final ResourceTree resourceTree = getResourceTree();
resourceTree.setOnLoadHandler(finished -> expand(currentAsset, resourceTree, finished));
resourceTree.fill(currentAsset);
FX_EVENT_MANAGER.addEventHandler(CreatedFileEvent.EVENT_TYPE, createdFileHandler);
FX_EVENT_MANAGER.addEventHandler(RequestSelectFileEvent.EVENT_TYPE, selectFileHandle);
FX_EVENT_MANAGER.addEventHandler(DeletedFileEvent.EVENT_TYPE, deletedFileHandler);
validateFileName();
EXECUTOR_MANAGER.addFXTask(getFileNameField()::requestFocus);
}
示例10: saveSenderData
import javafx.stage.Window; //导入依赖的package包/类
public void saveSenderData(ActionEvent actionEvent) {
FileChooser saveChooser = new FileChooser();
Window stage = senderMenuButton.getScene().getWindow();
saveChooser.setTitle("Zapisz dane wystawcy");
saveChooser.setInitialDirectory(new File(System.getProperty("user.home")));
saveChooser.setInitialFileName("File.txt");
File file = saveChooser.showSaveDialog(stage);
if (file != null) {
updateData();
try {
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(senderData.toString());
fileWriter.flush();
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例11: saveReceiverData
import javafx.stage.Window; //导入依赖的package包/类
public void saveReceiverData(ActionEvent actionEvent) {
FileChooser saveChooser = new FileChooser();
Window stage = receiverMenuButton.getScene().getWindow();
saveChooser.setTitle("Zapisz dane odbiorcy");
saveChooser.setInitialDirectory(new File(System.getProperty("user.home")));
saveChooser.setInitialFileName("file.txt");
File file = saveChooser.showSaveDialog(stage);
if (file != null) {
updateData();
try {
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(receiverData.toString());
fileWriter.flush();
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例12: showDialog
import javafx.stage.Window; //导入依赖的package包/类
public void showDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/diff/diff-view.fxml"));
try {
loader.setController(diffController);
DialogPane root = loader.load();
root.getStylesheets().add(getClass().getResource("/gui/diff/diff-view.css").toExternalForm());
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Diff Viewer");
alert.setResizable(true);
alert.setDialogPane(root);
alert.initModality(Modality.WINDOW_MODAL);
Window window = alert.getDialogPane().getScene().getWindow();
window.setOnCloseRequest(event -> window.hide());
alert.showAndWait();
} catch (IOException e) {
e.printStackTrace();
}
}
示例13: centerDialogOnScreen
import javafx.stage.Window; //导入依赖的package包/类
/**
* Utility method to center a Dialog/Alert on the middle of the current
* screen. Used to workaround a "bug" with the current version of JavaFX (or
* the SWT/JavaFX embedding?) where alerts always show on the primary
* screen, not necessarily the current one.
*
* @param dialog
* The dialog to reposition. It must be already shown, or else
* this will do nothing.
* @param referenceNode
* The dialog should be moved to the same screen as this node's
* window.
*/
public static void centerDialogOnScreen(Dialog<?> dialog, Node referenceNode) {
Window window = referenceNode.getScene().getWindow();
if (window == null) {
return;
}
Rectangle2D windowRectangle = new Rectangle2D(window.getX(), window.getY(), window.getWidth(), window.getHeight());
List<Screen> screens = Screen.getScreensForRectangle(windowRectangle);
Screen screen = screens.stream()
.findFirst()
.orElse(Screen.getPrimary());
Rectangle2D screenBounds = screen.getBounds();
dialog.setX((screenBounds.getWidth() - dialog.getWidth()) / 2 + screenBounds.getMinX());
// dialog.setY((screenBounds.getHeight() - dialog.getHeight()) / 2 + screenBounds.getMinY());
}
示例14: show
import javafx.stage.Window; //导入依赖的package包/类
public T show(Window parent) {
Stage stage = getStage();
stage.initModality(Modality.APPLICATION_MODAL);
focusOnFirstControl(stage.getScene().getRoot());
stage.showAndWait();
return getReturnValue();
}
示例15: showMessageDialog
import javafx.stage.Window; //导入依赖的package包/类
public static void showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) {
if (Platform.isFxApplicationThread()) {
_showMessageDialog(parent, message, title, type, monospace);
} else {
Object lock = new Object();
synchronized (lock) {
Platform.runLater(() -> {
_showMessageDialog(parent, message, title, type, monospace);
lock.notifyAll();
});
}
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}