Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Dialogs in JavaFX(How do I create a dialog in JavaFX/e(fx)clipse?)
Dialogs in JavaFX [message #1219354] Tue, 03 December 2013 13:57 Go to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
I am experimenting developing an Eclipse 4 application, using JavaFX as the UI toolkit. I have eclipse Kepler and e(fx)clipse installed. I need to be able to display dialogs (modal or modeless) and have not been able to figure out nor find good examples for doing this. Any help would be appreciated.
Re: Dialogs in JavaFX [message #1219359 is a reply to message #1219354] Tue, 03 December 2013 14:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
There's a bundle named org.eclipse.fx.ui.dialogs and there multi classes:

* Dialog: The base class of the Dialog system
* TitleAreaDialog: Similar to JFace counter part
* MessageDialog: A simple dialog similar to the JFace MessageDialog
* MessageTitleDialog: Similar to above but a subclass of TitleAreaDialog
* PromptInputDialog: I guess the name tells everything
* FontDialog: I guess the name speak for itself

Tom

On 03.12.13 14:57, Joseph Gagnon wrote:
> I am experimenting developing an Eclipse 4 application, using JavaFX as
> the UI toolkit. I have eclipse Kepler and e(fx)clipse installed. I need
> to be able to display dialogs (modal or modeless) and have not been able
> to figure out nor find good examples for doing this. Any help would be
> appreciated.
Re: Dialogs in JavaFX [message #1219360 is a reply to message #1219359] Tue, 03 December 2013 14:20 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
Hmm, I'm missing something in my setup. I have access to many org.eclipse.fx.* packages, but org.eclipse.fx.ui.dialogs is not among them.

Ah ha, there it is!

[Updated on: Tue, 03 December 2013 14:22]

Report message to a moderator

Re: Dialogs in JavaFX [message #1219361 is a reply to message #1219360] Tue, 03 December 2013 14:28 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
well if you've written e4-javafx applications you have to have it - at
least you stated this over in the e4 forum! The workbench dialogs in
javafx implementation are making use of it.

So how did you managed to create a pure javafx / e4 application? You
should have setup your target platform appropriately.

Tom

On 03.12.13 15:20, Joseph Gagnon wrote:
> Hmm, I'm missing something in my setup. I have access to many
> org.eclipse.fx.* packages, but org.eclipse.fx.ui.dialogs is not among them.
Re: Dialogs in JavaFX [message #1219365 is a reply to message #1219359] Tue, 03 December 2013 14:36 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
OK, found the FX dialogs package. It was sitting there all along and I had no idea. Embarrassed

Now, for example with the MessageDialog.open... methods, it wants a Window object passed as the parent. How can I obtain a reference to that? Below is an example.

...

public class MessageViewerPart {

  private MessagePane             msgPane;

  @Inject
  private MessageViewerModel      model;
  @Inject
  private MessageViewerController controller;

  @PostConstruct
  public void init(final MApplication app, BorderPane parent) {
    parent.setPadding(new Insets(5));
    parent.setCenter(createPane());

    bindControls();
  }

  private Node createPane() {
    BorderPane pane = new BorderPane();

    msgPane = new MessagePane();
    pane.setCenter(msgPane);

    pane.setBottom(createControlsPane());

    return pane;
  }

  private Node createControlsPane() {
    HBox pane = new HBox();
    pane.setSpacing(5);
    pane.setAlignment(Pos.CENTER);

    Button navFirstButton = new Button("First");
    pane.getChildren().add(navFirstButton);

    navFirstButton.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {
        MessageDialog.openInformationDialog(<<need Window reference>>, "Title", "Message");
      }
    });

    return pane;
  }

...


Passing the BorderPane "parent" (injected in the PostContruct method init) did not work.
Re: Dialogs in JavaFX [message #1219366 is a reply to message #1219361] Tue, 03 December 2013 14:37 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
I did have to add it to the plugin.xml required plug-ins list.
Re: Dialogs in JavaFX [message #1219369 is a reply to message #1219365] Tue, 03 December 2013 14:45 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
window is the base class of stage. You can get it from
node.getScene().getWindow() IIRC or in an e4 context you can do:

class MyPart {
@Inject
Stage stage

}


Tom

On 03.12.13 15:36, Joseph Gagnon wrote:
> OK, found the FX dialogs package. It was sitting there all along and I
> had no idea. :blush:
> Now, for example with the MessageDialog.open... methods, it wants a
> Window object passed as the parent. How can I obtain a reference to
> that? Below is an example.
>
>
> ..
>
> public class MessageViewerPart {
>
> private MessagePane msgPane;
>
> @Inject
> private MessageViewerModel model;
> @Inject
> private MessageViewerController controller;
>
> @PostConstruct
> public void init(final MApplication app, BorderPane parent) {
> parent.setPadding(new Insets(5));
> parent.setCenter(createPane());
>
> bindControls();
> }
>
> private Node createPane() {
> BorderPane pane = new BorderPane();
>
> msgPane = new MessagePane();
> pane.setCenter(msgPane);
>
> pane.setBottom(createControlsPane());
>
> return pane;
> }
>
> private Node createControlsPane() {
> HBox pane = new HBox();
> pane.setSpacing(5);
> pane.setAlignment(Pos.CENTER);
>
> Button navFirstButton = new Button("First");
> pane.getChildren().add(navFirstButton);
>
> navFirstButton.setOnAction(new EventHandler<ActionEvent>() {
> @Override
> public void handle(ActionEvent event) {
> MessageDialog.openInformationDialog(<<need Window reference>>,
> "Title", "Message");
> }
> });
>
> return pane;
> }
>
> ..
>
>
> Passing the BorderPane "parent" (injected in the PostContruct method
> init) did not work.
Re: Dialogs in JavaFX [message #1219370 is a reply to message #1219366] Tue, 03 December 2013 14:46 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Sure it is not mandatory and you can use any other lib as well so - yes
you need to require it actively.

Tom

On 03.12.13 15:37, Joseph Gagnon wrote:
> I did have to add it to the plugin.xml required plug-ins list.
Re: Dialogs in JavaFX [message #1219371 is a reply to message #1219369] Tue, 03 December 2013 14:47 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
Just out of curiosity, what is IIRC you reference?
Re: Dialogs in JavaFX [message #1219374 is a reply to message #1219359] Tue, 03 December 2013 15:06 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
Sweet! It looks like this will do what I need quite nicely. I will do some more experimenting, implementing a more involved dialog, but I don't foresee any problems at this point. Thanks a lot Tom.
Re: Dialogs in JavaFX [message #1219419 is a reply to message #1219371] Tue, 03 December 2013 17:51 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://www.internetslang.com/IIRC-meaning-definition.asp

Tom

On 03.12.13 15:47, Joseph Gagnon wrote:
> Just out of curiosity, what is IIRC you reference?
Re: Dialogs in JavaFX [message #1815616 is a reply to message #1219371] Mon, 07 October 2019 09:23 Go to previous message
Sujit Singh is currently offline Sujit SinghFriend
Messages: 1
Registered: October 2019
Junior Member
Joseph Gagnon wrote on Tue, 03 December 2013 14:47
Just out of curiosity, what is IIRC you reference?


IIRC means "If I Remember Correctly".
Previous Topic:Eclipse + Tycho + Maven + OSGI + Java FX + Java >= 11?
Next Topic:Enable fxml parsing in existing JavaFX/Maven project
Goto Forum:
  


Current Time: Thu Dec 26 11:53:02 GMT 2024

Powered by FUDForum. Page generated in 0.06221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top