Comments (4)
Configuration of modality for FXFileChooserStage
is already working. This can be achieved by calling Stage.initModality(...)
method like:
PathFilter[] filters = new PathFilter[] {all, xml, xlsx, na0, txt, exe, combined};
FXFileChooserStage fileChooserStage = FXFileChooserStage.create(Skin.DARK, local, filters);
fileChooserStage.initModality(Modality.NONE);
Button button = new Button("FXFileChooserStage (Skin.DARK, Modality.NONE)");
button.setOnAction(e -> {
if (fileChooserStage.isShowing()) {
e.consume(); // JavaFX will otherwise complain if stage is already showing
return;
}
Optional<Path> selection = fcDarkNonModal.showOpenDialog(primaryStage);
// handle selection here
});
Alternatively one can make use of the class FileChooser
which can be embedded as a control like a button into any other view or even in FXML. Modality is not known as a concept to the FileChooser
class itself. It only plays a role when placed in a dialog or separate stage.
from fxfilechooser.
Hello,
Thank you for this product.
I would like to open a FXFileChooser in non modal manner like JFoenix JFXDialog.
Intention is to use it in JPro where the UI thread cannot be blocked.
Does this solving this issue achieve it?
from fxfilechooser.
Hello, well there will be a new version latest within next week, where modality will be configurable. Currently the default is Modality.APPLICATION_MODAL
. Modality does not block the UI thread, it configures if underlaying windows (e.g. the main application window) are focusable and selectable. For case of Modality.APPLICATION_MODAL
, the parent window of the dialog is not accessible as long the FXFileChooserStage is visible. After closing the FXFileChooserStage, the parent window again becomes accessible.
If in JPro any errors occurr due to JavaFX thread blocking, this is a bug and I would have to dig into.
To configure modality I plan to either modify the FXFileChooserStage.create()
method or create some kind of a builder, a fluent API.
@Override
public void start(Stage primaryStage) throws Exception {
Button button = new Button("Show File Chooser");
FXFileChooserStage fc = FXFileChooserStage.create(Skin.DARK);
/* assume default Modality.WINDOW or Modality.NONE or request custom cas */
FXFileChooserStage fc = FXFileChooserStage.create(Skin.DARK)
.modality( ... );
// or
FXFileChooserStage fc = FXFileChooserStage.create(Skin.DARK, Modality.NONE);
button.setOnAction(evt-> fc.showOpenDialog(primaryStage).ifPresent(this::showSelection));
Scene scene = new Scene(button);
primaryStage.setScene(scene);
primaryStage.setTitle("Demo");
primaryStage.show();
}
If the stage created by FXFleChooser causes trouble in JPro, I don't know yet how to solve it. I will try out with JPro.
Which Java and JavaFX version do you run?
Have you already tried to run FXFleChooser in JPro?
Running in JPro the FXFileChooser will show files on the server - which, you probably dont want to do. This can pose a security threat to the server. But, it depends on your use case. FXFileChooser running in browser will not be able to show the clients file system. This kind of access is blocked by all web browsers for security reasons.
from fxfilechooser.
Hello,
I use Java 8 and have not actually tried with JPro and for some reason thought FXFileChooser is always Modal.
And yes FXFileChooser will not allow me to browse files on client I have learned.
Thank you for the explanation.
from fxfilechooser.
Related Issues (20)
- Reduce memory consumption for large folders
- Progress Bar slowing down refresh of large directories down
- FileChooser hangs when a (removable) drive letter/location is entered via textfield
- FileChooserDialog does not show the actual location in some cases HOT 1
- Add checkstyle and editorconfig to ensure consistent formatting conventions HOT 1
- POM dependencies outdated
- Exclude demo code from build artifact
- Create Java-8 compatible release without demos HOT 1
- Fix performance issue in directory browser for huge directories HOT 1
- Create Java-9 compatible release including the module-info HOT 1
- Create Java-11/OpenJFX11 compatible release including the module-info HOT 1
- Create Java-16/OpenJFX16 compatible release including the module-info HOT 1
- Make DirectoryChooser and FileChooser compatible with SceneBuilder HOT 1
- Make file chooser configurable using FXML tags.
- Replace progress bar in director ychooser with an animation + add control to abort folder scanning.
- Make `SwingFileChooser` a true drop in replacement for `JFileChooser`
- When entering ".." in the FileBrowser text field, the directory should navigate one level up HOT 1
- Add option to make file search case insensitive HOT 2
- Problems with v0.0.11 in a Gradle build HOT 7
- Add flatten-maven-plugin to build in order to avoid need for parent pom to be published HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fxfilechooser.