How To Create Modal Stage Window From A JFrame In Java FX 2

Well, there is no solution to making a Stage window modal when opened from a JFrame. At least not directly. I scoured through countless forums and blog posts but their solutions never made it modal.

A future version of Java FX may solve this problem. In the meantime, this is how I did it in Java FX 2. The same JDialog will be instantiated but set to invisible. I did this by calling the setUndecorated() method to true.

Within the JDialog class, that is where I called the Java FX code to open a Stage window dialog.

So now it is modal. But when you click the JFrame in the task bar in the Windows OS below, the Stage window is not sent to the front. This is not the behavior we want for a modal window, right?

What I did was to add a FocusListener in the JDialog custom class so that when it is in focus (since it is modal), it will call the Stage window object and send it to the front.

Here is the custom JDialog class I made. 

 
Then just call that from within your JFrame.

The StageModalDialog class is a custom class I made that inherits from the Stage class.

Donations appreciated. Every little $ helps. Or click Google +1.

How To Create A ListView With Title Header That Expands & Collapses In Java FX

There is no component that does this within the API of Java FX and Google searches gave me nothing so instead, I created my own.

The concept is the same with tables where rows are grouped and row headers give you the option to expand and collapse them.

For List View, I had to make my own CellFactory in order to make this work. I was surprised that I was able to make one. If this was Swing, it might have been different.

This is how my component looks like.

javafx_listview_withexpandcollapse

 

I created an entity class that contains the title and description. Let us call the class, Note. The class has an extra boolean parameter which I use told hold the state of the title if it is expanded or not. 

 
And this is how I configured my List View

 
For each entry in the list, I used a vertical box to display the contents. When the title is clicked to expand the description, the VBox will add a child so that it will be shown. If it is collapse, it will be removed.

Simple, right? Cell factories are very handy and flexible in such a way that you can render what you want displayed to the user any way you want to.

If you noticed, there is a method called createArrowPath(). That is a convenience method I made to return an SVGPath object to be used as the arrow icon beside the title header. It takes a parameter height which should be the height of the List View

Donations appreciated. Every little $ helps. Or click Google +1.

Storage As A Service

Amcom Storage as a Service solutions provide an unmatched level of flexibility for clients’ storage needs. Storage as a service can address users’ file storage, file sharing, computer backup and performance storage needs with scaleable, efficient and low risk solutions.

Advantage of getting these kinds of services is that there is no risk to the users themselves. All you need to do is backup, upload or download files and that is it. No need to worry on hardware maintenance, software upgrades and other technical concerns.

In the process, you get to enjoy the highest level of security through encrypted platforms with easy to use acces controls. Plus, by using amcom cloud storage solutions, users will experience world class data protection technology and tiered security management policies ensure privacy and integrity of all critical business files.

With SAAS, data is intelligently cached in and out of the utility storage platform thereby providing fast access to recently used data. Private and secure file exchange without having to set up unique access for each party is beneficial to users using the service.

Amcom also has an optional local cloud file server replacement solution for added functionality and file access without internet. Just in case, right? You never know.

Access anywhere, anytime and upload and download files all you want.

Donations appreciated. Every little $ helps. Or click Google +1.

Related Posts Plugin for WordPress, Blogger...