本文整理汇总了Java中javafx.stage.FileChooser.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java FileChooser.setTitle方法的具体用法?Java FileChooser.setTitle怎么用?Java FileChooser.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.stage.FileChooser
的用法示例。
在下文中一共展示了FileChooser.setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSelectImage
import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void handleSelectImage(MouseEvent mouseEvent) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(imageChooserTitle);
fileChooser.getExtensionFilters().add(new ExtensionFilter("PNG", "*.png"));
final File file = fileChooser
.showOpenDialog(((Node) mouseEvent.getSource()).getScene().getWindow());
if (file == null) {
return;
}
try {
final byte[] image = ImageUtils.readImage(file);
model.imageRaw.set(image);
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: exportRootSummaries
import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
void exportRootSummaries(ActionEvent event) throws FileNotFoundException, IOException {
FileChooser saveChooser = new FileChooser();
saveChooser.setTitle("Export (Save) data");
saveChooser.setInitialFileName(pkg.getName() + "_root_path_summary.xlsx");
File saveFile = saveChooser.showSaveDialog(null);
if (saveFile != null) {
FileOutputStream out = new FileOutputStream(saveFile);
String[] headers = new String[]{
"Root folder", "Count"
};
ReportUtil.exportSpreadsheet(out, pkgContents.getBaseCounts().entrySet(), headers,
Map.Entry::getKey,
Map.Entry::getValue
);
out.close();
}
}
示例3: exportMjlog
import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void exportMjlog(ActionEvent actionEvent) throws IOException {
if (this.tableView.getSelectionModel().getSelectedItem() != null) {
InfoSchema infoSchema = this.tableView.getSelectionModel().getSelectedItem();
String content = this.databaseService.findMjlogById(infoSchema.getId());
if (content != null) {
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialFileName(infoSchema.getId());
fileChooser.setTitle("Save mjlog File");
fileChooser.getExtensionFilters().add(
new FileChooser.ExtensionFilter("mjlog Files", "*.mjlog"));
File selectedFile = fileChooser.showSaveDialog(this.dateListView.getScene().getWindow());
if (selectedFile != null) {
Files.copy(new ByteArrayInputStream(content.getBytes()), selectedFile.toPath());
}
}
}
}
示例4: loadPlugin
import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
private void loadPlugin() {
FileChooser chooser = new FileChooser();
chooser.setTitle("Choose a plugin");
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Plugin", "*.jar"));
List<File> files = chooser.showOpenMultipleDialog(root.getScene().getWindow());
if (files == null) {
return;
}
files.forEach(f -> {
try {
// TODO save this in user preferences
PluginLoader.getDefault().loadPluginJar(f.toURI());
} catch (IOException | IllegalArgumentException e) {
log.log(Level.WARNING, "Could not load jar", e);
// TODO improve the dialog; use something like what GRIP has
Alert alert = new Alert(Alert.AlertType.ERROR, null, ButtonType.OK);
alert.setTitle("Could not load plugins");
alert.setHeaderText("Plugins in " + f.getName() + " could not be loaded");
alert.setContentText("Error message:\n\n " + e.getMessage());
alert.showAndWait();
}
});
}
示例5: handleExportToPNG
import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
* A handler for the export to PNG option in the context menu.
*/
private void handleExportToPNG() {
FileChooser chooser = new FileChooser();
chooser.setTitle("Export to PNG");
FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
"Portable Network Graphics (PNG)", "png");
chooser.getExtensionFilters().add(filter);
File file = chooser.showSaveDialog(getScene().getWindow());
if (file != null) {
try {
ExportUtils.writeAsPNG(this.canvas.getChart(), (int) getWidth(),
(int) getHeight(), file);
} catch (IOException ex) {
// FIXME: show a dialog with the error
throw new RuntimeException(ex);
}
}
}
示例6: openFileChooser
import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void openFileChooser(){
FileChooser fileChooser = new FileChooser();
ArrayList<String> l = new ArrayList<String>();
l.add("*.txt");
l.add("*.text");
fileChooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("Fichiers texte",l)
);
fileChooser.setTitle("Choisir verbatim Entretien");
fichierChoisi = fileChooser.showOpenDialog(null);
if(fichierChoisi != null){
newEntrFileName.setText(fichierChoisi.getPath());
canCreate.set(false);
}
else {
newEntrFileName.setText("/");
}
}
示例7: loadReceiverData
import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void loadReceiverData(ActionEvent actionEvent) {
FileChooser chooser = new FileChooser();
Window stage = receiverMenuButton.getScene().getWindow();
chooser.setTitle("Wybierz plik z danymi odbiorcy");
chooser.setInitialDirectory(new File(System.getProperty("user.home")));
File file = chooser.showOpenDialog(stage);
if (file != null) {
String jsonData = null;
try {
InputStream inputStream = new FileInputStream(file);
jsonData = org.apache.commons.io.IOUtils.toString(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
if (jsonData != null) {
fillReceiverData(new JSONObject(jsonData));
}
}
}
示例8: makeChooser
import javafx.stage.FileChooser; //导入方法依赖的package包/类
private FileChooser makeChooser (String extensionAccepted) {
FileChooser result = new FileChooser();
result.setTitle("Choose Game XML File");
// pick a reasonable place to start searching for files
result.setInitialDirectory(new File(System.getProperty("user.dir")));
result.getExtensionFilters().setAll(new ExtensionFilter("XML Files", extensionAccepted));
return result;
}
示例9: addFileChooser
import javafx.stage.FileChooser; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public WizardStepBuilder addFileChooser(final String fieldName, final String fileChooseLabel, final String startDir,
final FileChooser.ExtensionFilter... filters)
{
final WizardStep current = this.current;
final HBox box = new HBox();
final JFXButton button = new JFXButton(fileChooseLabel);
button.setStyle("-fx-text-fill: BLACK;-fx-font-size: 18px;-fx-opacity: 0.7;");
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(fileChooseLabel);
fileChooser.setInitialDirectory(new File(startDir));
fileChooser.getExtensionFilters().addAll(filters);
this.current.getData().put(fieldName, new SimpleObjectProperty<File>());
button.setOnAction(
e -> current.getData().get(fieldName).setValue(fileChooser.showOpenDialog(MineIDE.primaryStage)));
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(button, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
final JFXTextField text = new JFXTextField();
text.setEditable(false);
this.current.getData().get(fieldName).addListener(
(ChangeListener<File>) (observable, oldValue, newValue) -> text.setText(newValue.getAbsolutePath()));
box.getChildren().addAll(text, button);
this.current.add(box, 1, this.current.getData().size() - 1);
return this;
}
示例10: generateBackupCopy
import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
* Generates a copy of the database and lets
* the user choose where to save it
*/
private void generateBackupCopy() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Backup Copy");
fileChooser.setInitialDirectory(
new File(System.getProperty("user.home"))
);
fileChooser.setInitialFileName("Backup Copy " + LocalDate.now() + ".db");
FileChooser.ExtensionFilter databaseExtensionFilter =
new FileChooser.ExtensionFilter(
"DB - Database (.db)", "*.db");
fileChooser.getExtensionFilters().add(databaseExtensionFilter);
fileChooser.setSelectedExtensionFilter(databaseExtensionFilter);
File backupFile = fileChooser.showSaveDialog(currentStage);
if (backupFile != null) {
try {
File theDatabase = new File(DatabaseHelper.DATABASE_PATH_NAME);
if (!theDatabase.exists()) {
DatabaseHelper.createDatabase();
}
Files.copy(theDatabase.toPath(), backupFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例11: saveAs
import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
public boolean saveAs() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save");
fileChooser.getExtensionFilters().add(new ExtensionFilter("Style Sheet", "*.css"));
fileChooser.setInitialDirectory(recentSupport.getLastFile().getParentFile());
fileChooser.setInitialFileName(currentTabEntity().getValue().name.get());
File selectedFile = fileChooser.showSaveDialog(stage);
if (selectedFile == null) {
return false;
} else {
return andFinal(() -> saveToFile(selectedFile),
b -> ifThat(b).todo(() -> currentTabEntity().getValue().file.setValue(selectedFile)));
}
}
示例12: handleExportToPDF
import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
* A handler for the export to PDF option in the context menu.
*/
private void handleExportToPDF() {
FileChooser chooser = new FileChooser();
chooser.setTitle("Export to PDF");
FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter(
"Portable Document Format (PDF)", "pdf");
chooser.getExtensionFilters().add(filter);
File file = chooser.showSaveDialog(getScene().getWindow());
if (file != null) {
ExportUtils.writeAsPDF(this.canvas.getChart(), (int) getWidth(),
(int) getHeight(), file);
}
}
示例13: exportToCsv
import javafx.stage.FileChooser; //导入方法依赖的package包/类
private void exportToCsv() {
try {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Export to .csv");
fileChooser.getExtensionFilters().add(new ExtensionFilter("CSV files", "*.csv"));
File file = fileChooser.showSaveDialog(new Stage());
if (file == null){
return;
}
BufferedWriter br = new BufferedWriter(new FileWriter(file.getPath()));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < plotData.getAllTraces().size(); i++) {
sb.append("\n");
sb.append(plotData.getAllTraces().get(i).getTraceName());
sb.append("\n");
for (int j = 0; j < plotData.getAllTraces().get(i).getxArray().length; j++) {
if (plotData.getAllTraces().get(i).getxArray() == null) {
br.close();
return;
}
sb.append(plotData.getAllTraces().get(i).getxArray()[j]);
if (plotData.getAllTraces().get(i).getyArray() != null) {
sb.append(",");
sb.append(plotData.getAllTraces().get(i).getyArray()[j]);
}
if (plotData.getAllTraces().get(i).getzArray() != null) {
sb.append(",");
sb.append(plotData.getAllTraces().get(i).getzArray()[j]);
}
sb.append("\n");
}
}
br.write(sb.toString());
br.close();
} catch (IOException e) {
logger.error("FileWriterException ", e);
}
return;
}
示例14: askFileName
import javafx.stage.FileChooser; //导入方法依赖的package包/类
private File askFileName() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save JWK File");
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("JWK result (*.jwk)", "*.jwk"));
fileChooser.setInitialFileName("*.jwk");
File result = fileChooser.showSaveDialog(primaryStage);
if (result != null) {
if (!result.getName().endsWith(".jwk")) {
// FIXME
throw new RuntimeException(result.getName() + " has no valid JWK-extension.");
}
}
return result;
}
示例15: getFileChooserForImage
import javafx.stage.FileChooser; //导入方法依赖的package包/类
private File getFileChooserForImage(final Stage primaryStage) {
final FileChooser fileChooser = new FileChooser();
fileChooser.getExtensionFilters()
.add(new FileChooser.ExtensionFilter("*" + " files (*." + "*" + ")", "*." + "*"));
Stream.of(ImageFilters.values()).forEach(item -> {
final String fileExt = item.toString();
fileChooser.getExtensionFilters()
.add(new FileChooser.ExtensionFilter(fileExt + " files (*." + fileExt + ")", "*." + fileExt));
});
fileChooser.setTitle("Choose your images:");
return fileChooser.showOpenDialog(primaryStage);
}