MonologFX Styling

146 views
Skip to first unread message

David

unread,
Mar 27, 2013, 5:35:27 PM3/27/13
to jfxtra...@googlegroups.com
Doe the addStylesheet() method actually work? I've not been able to load the style resource even when giving an explicit, hard-wired resource file name. Looking at the source, I've tried to load a style resource for a JavaFX Stage (the base type for MonologFX) and not been able to get that to work either.

        System.out.println(primaryStage.getClass().getResource("Styles.css").toExternalForm());

just blows up.

If I'm missing something could someone post a working example?

Thanks for the help,

David

Mark Heckler

unread,
Mar 27, 2013, 5:50:34 PM3/27/13
to jfxtra...@googlegroups.com
Hi David,

I've lost a machine between the time that I wrote that and now, but since I am a bit fanatical about backups (!), I should be able to send you a copy of my earlier test code shortly. If not, I'll whip something up and post it as soon as I can.

More soon,
Mark




--
You received this message because you are subscribed to the Google Groups "JFXtras Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jfxtras-user...@googlegroups.com.
To post to this group, send email to jfxtra...@googlegroups.com.
Visit this group at http://groups.google.com/group/jfxtras-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mark Heckler

unread,
Mar 27, 2013, 8:23:48 PM3/27/13
to jfxtra...@googlegroups.com
Hi David,

I couldn't find my "old stuff" and wanted to get back with you as soon as I could, so I just plugged in a couple things and had no problems. Here is what I did:

1) Placed a .css file into corresponding "dialogs" resources directory (where the dialog icon files are) within jfxtras-labs (I actually just used my hecklerm/MonologFX for a quick test, but the code is the same)
2) Cleaned & Built jfxtras-labs (as I just included that .jar in my test project)
3) Placed the following code in my test project that uses the Monologs:

        MonologFX mono = MonologFXBuilder.create()
                .modal(true)
                .type(MonologFX.Type.QUESTION)
                .message("Welcome to MonologFX! Does this look like it might be useful?")
                .titleText("Important Announcement")
                .button(mlb)
                .button(mlb2)
                .buttonAlignment(MonologFX.ButtonAlignment.RIGHT)
                .stylesheet("Icy.css")
                .build();
        
        //mono.addStylesheet("Icy.css");

4) Run to test. I did try both the Builder approach (above) and non-builder (commented out, last line). Both seemed to work fine.

Before:
Inline image 2

After (with Icy.css):
Inline image 1

Please give it a try and let me know.

Hope this helps,
Mark

image.png
image.png

DAVIDANDE...@yahoo.com

unread,
Mar 28, 2013, 4:10:31 PM3/28/13
to jfxtra...@googlegroups.com
Hi Mark,

Thanks for the quick reply.

Do I understand correctly that the new resource file, the .css file, has to be in the JFXtras jar in the same place where you put the icons? If so, that would be my problem; I just put it in the project directory where I use it with other JavaFX components. Does that mean I would have to rebuild the jfxtras any time I wanted to change the style?

I have tried to build jfxtras-labs-2.2 straight out of the repository, but it fails with missing package and symbol errors. Not sure what the system is complaining about since the packages it complains about are right there in the JavaFX jar. It looks like the build file correctly locates the jfxrt.jar file. The Gradle output stops after 100 errors, but assuming it compiles things in alphabetical order, it looks like every import statement for a JavaFX package in the source fails to compile. (The plain ole Java package imports don't generate any errors.)

JDK 1.7.0 Update 17 (64 bit)
JavaFX 2.2.7
Windows 7 Pro (64 bit)

I'm not familiar with Gradle, but don't see anything obviously wrong with the build or property files.

Building a Java project with the pre-compiled 2.2 rc5 jar downloaded from the web seems to work as expected (with the exception of the styles of course.) The resource bundles don't get loaded either.

My Java may be a bit rusty (the actual project I am working on is written in Clojure), but I don't see any problems with jfxtras jar.

Any other ideas?

Thanks again,

David

DAVIDANDE...@yahoo.com

unread,
Mar 28, 2013, 4:28:29 PM3/28/13
to jfxtra...@googlegroups.com, DAVIDANDE...@yahoo.com
Spoke too soon. There was an extra "/rt" subdirectory in the path to the jfxrt.jar file. Edited build file and it works now. Now to try your solution.

DAVIDANDE...@yahoo.com

unread,
Mar 28, 2013, 4:38:37 PM3/28/13
to jfxtra...@googlegroups.com, DAVIDANDE...@yahoo.com
Hi Again Mark,

Your suggestion works. Copying the new css file into the resources directory and rebuilding jfxtras-labs.jar yields a working program with revised styling in the dialog. (There are still warnings about not finding the English resource bundle.)

Any thoughts about modifications such that the resources could be changed without recompiling the jar?

Thanks,

David

Mark Heckler

unread,
Mar 28, 2013, 5:15:15 PM3/28/13
to jfxtra...@googlegroups.com
Hi David,

As it stands now, yes, that's how you'd have to do it. Note that you can include several .css files in your resources and build the .jar, then switch between them repeatedly (if you'd want to do) at runtime.  :-)

I'll have to try to rebuild with Gradle again shortly; I'm just getting back to a starting point again with my dev machine. :( Last time I tried it worked, though. Adding that to the list!

If you want to just do a quick test with MonologFX & the style sheet capability, you're welcome to download just that code from my Github repo (hecklerm/MonologFX), drop a .css file in there with everything else (nothing fancy there), & build it. That might help you isolate any potential issues/usage quirks you may be experiencing.

Hope this helps!

Mark

David

unread,
Mar 28, 2013, 6:14:03 PM3/28/13
to jfxtra...@googlegroups.com
Good idea. I'll give it a try.

David

unread,
Apr 7, 2013, 3:36:46 AM4/7/13
to jfxtra...@googlegroups.com
Hi Again,

Turns out I could just create a package path (jfxtras/labs/diaglogs) in my source directory and put the style sheet in there. The build tool (Leiningen) put the resource file in the correct package in the jar it created for the project. With the style sheet in the correct location in the jar, it loaded correctly without having to re-compile and rebuild the jfxtras jar.

David

Mark Heckler

unread,
Apr 7, 2013, 11:18:31 AM4/7/13
to jfxtra...@googlegroups.com
Hi David,

Glad it's working for you! Never used Leiningen, had to check it out. :-)

Hoping to do some dialog-tweaking today, as a matter of fact. Have a great weekend!

All the best,
Mark

David

unread,
May 8, 2013, 1:57:04 PM5/8/13
to jfxtra...@googlegroups.com
Hi Mark,

Thought you might be interested in a short blog post about this topic. It just talks about including the desired style sheet in a directory structure that parallels the structure used in MonologFX. There is a blog post describing the program that uses the dialogs here.

Best Regards,

David

Mark Heckler

unread,
May 8, 2013, 2:45:36 PM5/8/13
to jfxtra...@googlegroups.com
Hi David,

Nice articles, nice blog! I just added you to my Feedly RSS list, so keep it coming. ;-)

More changes and improvements coming to MonologFX, as with the rest of JFXtras, so please pass along any thoughts/ideas you may have. Thanks again for the input and the kind words!

All the best,
Mark
Reply all
Reply to author
Forward
0 new messages