NotificationPane Question

1,041 views
Skip to first unread message

Derek F

unread,
Oct 21, 2014, 5:51:35 PM10/21/14
to control...@googlegroups.com
Hello.

I was wondering if it is possible to use a NotificationPane with a screen built in SceneBuilder.

For example I have a dynamically loaded tab which was built with FXML.

It starts with a VBox and linked via the fx:id

@FXML
VBox vbox;

private NotificationPane np;

I attempted in the initialize of the controller to do the following;

np = new NotificationPane(vbox);
np.setText("my notification");
np.setShowFromTop(true);

Then in a clickHandler()
np.show();

I get no errors but nothing displays.

Just wondering if that is possible.

Thanks

Adrian Romanelli

unread,
Oct 21, 2014, 6:52:56 PM10/21/14
to control...@googlegroups.com
I too am lookiing for this information.  I'd rather work with it via Scene Builder if I could, but when I imported via "Import Jar/FXML File..." and selected the jar file, NotificationPane was not added to the 'Custom' section in Scene Builder.  Other controls were though.

Otherwise, I would like to know how to programmaticaly use it in relation to a scene built in SceneBuilder.

Derek F

unread,
Oct 22, 2014, 10:12:49 AM10/22/14
to control...@googlegroups.com
One moe detail to my post. I walked through the code with the debugger and all seems initialized, however the NotificationPane node doesn't seem to appear in ScenicView while running or I can't find it

Jonathan Millman

unread,
Oct 22, 2014, 10:52:45 AM10/22/14
to control...@googlegroups.com
in your code snippet you never add your NotificationPane (NP) to a scenegraph.

I have used a notification pane with the following code which wraps some FXML defined node in a NP and then "injects" the NP into the scenegraph where the content node was previously (using a BorderPane in this example):


        notificationPane = new NotificationPane(internalBorderPane.getCenter());
        internalBorderPane.setCenter(notificationPane);

        //setup up notification pane properties
        notificationPane.getStyleClass().add(NotificationPane.STYLE_CLASS_DARK);
        notificationPane.setText("New data available for review.");
        notificationPane.setGraphic(new ImageView(INFO));
        notificationPane.setShowFromTop(false);
        notificationPane.getActions().setAll(new AbstractAction("Review Data") {
            @Override
            public void handle(ActionEvent event) {
                runWizard();
                notificationPane.hide();
            }
        });


I hope this helps.  I also would like to be able to use NotificationPane in scenebuilder, but don't have the time to make it work.

Derek F

unread,
Oct 22, 2014, 1:21:10 PM10/22/14
to control...@googlegroups.com
Thanks for the suggestion, however I don't want to replace what I have, just append to it.

I just wanted to add the NP to the VBox or AnchorPane, but that still didn't seen to work

Jonathan Millman

unread,
Oct 22, 2014, 1:39:07 PM10/22/14
to control...@googlegroups.com
but NotificationPane is designed to wrap some other content in the scenegraph ...

On Wed, Oct 22, 2014 at 1:21 PM, Derek F <purrin...@gmail.com> wrote:
Thanks for the suggestion, however I don't want to replace what I have, just append to it.

I just wanted to add the NP to the VBox or AnchorPane, but that still didn't seen to work

--
You received this message because you are subscribed to a topic in the Google Groups "ControlsFX" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/controlsfx-dev/XRIgrFbrVs8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to controlsfx-de...@googlegroups.com.
To post to this group, send email to control...@googlegroups.com.
Visit this group at http://groups.google.com/group/controlsfx-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/controlsfx-dev/02f16e15-da75-4eb0-9b76-1c7d45bb215b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jonathan Millman
www.jmillman.com

Purring Pigeon

unread,
Oct 22, 2014, 3:09:42 PM10/22/14
to control...@googlegroups.com
That's what I was doing - at least I think I was doing. 

np = new NotificationPane(vbox);

Where vbox is linked via the FXML by id. 


Jonathan Millman

unread,
Oct 22, 2014, 3:26:40 PM10/22/14
to control...@googlegroups.com

right, that makes a new notification pane with the vbox as its content, but now you need to put the notification pane into the scenegraph where  the vbox was (don't worry, the vbox will come along with the notification pane)  

hopefull the attached diagram helps explain the situation (arrows indicate "is a child of")
Untitled.png

Purring Pigeon

unread,
Oct 22, 2014, 4:12:52 PM10/22/14
to control...@googlegroups.com
It clarifies the relationship I want, however I'm having a tough time figuring out how to do this. 

My scene that I am working with starts with 
Vbox
    AnchorPane
        Various Controls. 


If I do 
np = new NotificationPane (vbox);

I'm not sure how to replace the vbox on the scene graph with the NotificationPane. 

I don't have a reference higher than the vbox which was added to a tab via FXML. 


I was able to do it like this (so thanks!!!) but I was hoping to wrap the top most node on the scene. 

package org.sif.javafx.screen1;

 

import javafx.collections.ObservableList;

import javafx.fxml.FXML;

import javafx.scene.Node;

import javafx.scene.control.TextArea;

import javafx.scene.layout.AnchorPane;

import javafx.scene.layout.VBox;

 

import org.controlsfx.control.NotificationPane;

 

public class ScreenOneController {

                

                @FXML

                TextArea ta;

                @FXML

                VBox vbox;

                

                

                NotificationPane notificationPane;

                

                public void initialize() {

                                

                                ObservableList<Node> list = vbox.getChildren();

                                

                                Node n = list.iterator().next();

                                AnchorPane nn = (AnchorPane)n;

                                

                                notificationPane = new NotificationPane(nn);

        notificationPane.getStyleClass().add(NotificationPane.STYLE_CLASS_DARK);

        notificationPane.setText("New data available for review.");

        notificationPane.setShowFromTop(false);

         

        vbox.getChildren().clear();

        vbox.getChildren().add(notificationPane);

                }

                

                @FXML

                private void okClickHandler() {

                                notificationPane.show();

                }

 

}


For more options, visit https://groups.google.com/d/optout.
<Untitled.png>

Jonathan Millman

unread,
Oct 23, 2014, 3:02:07 PM10/23/14
to control...@googlegroups.com
is the anchorpane the onlything in the vbox?  why not wrap the anchor pane instead?


For more options, visit https://groups.google.com/d/optout.



--
Jonathan Millman
www.jmillman.com

Purring Pigeon

unread,
Oct 23, 2014, 3:14:30 PM10/23/14
to control...@googlegroups.com
It is. I added the vbox to get to it. I'm just not sure how to replace the anchor with the unknown parent. 


Jonathan Millman

unread,
Oct 23, 2014, 4:04:25 PM10/23/14
to control...@googlegroups.com
is there a reason you can't do vbox.getChildren().add(notificationPane)   ?


For more options, visit https://groups.google.com/d/optout.



--
Jonathan Millman
www.jmillman.com

Purring Pigeon

unread,
Oct 23, 2014, 4:57:43 PM10/23/14
to control...@googlegroups.com
I decided it made more sense to perform this logic where I dynamically load and position the FXML into the scene and pass a reference to the NotificationPane to the controller. This keeps the code from having redundant duplication.

Thanks for the help. Your insights helped seal direction. 


Jonathan Millman

unread,
Oct 23, 2014, 5:03:22 PM10/23/14
to control...@googlegroups.com
that makes sense too!  I am glad I could help.


For more options, visit https://groups.google.com/d/optout.



--
Jonathan Millman
www.jmillman.com

Jonathan Giles

unread,
Oct 23, 2014, 5:08:36 PM10/23/14
to control...@googlegroups.com
Thanks Jonathan for your support of other users of ControlsFX - it's great to see people stepping up to help others on this mailing list.
-- Jonathan

You received this message because you are subscribed to the Google Groups "ControlsFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to controlsfx-de...@googlegroups.com.

To post to this group, send email to control...@googlegroups.com.
Visit this group at http://groups.google.com/group/controlsfx-dev.
Reply all
Reply to author
Forward
0 new messages