Giter Club home page Giter Club logo

Comments (4)

Oliver-Loeffler avatar Oliver-Loeffler commented on June 16, 2024 1

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.

Hugolarson avatar Hugolarson commented on June 16, 2024

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.

Oliver-Loeffler avatar Oliver-Loeffler commented on June 16, 2024

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.

Hugolarson avatar Hugolarson commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.