Home > javafx > JavaFX – Custom "Window"

JavaFX – Custom "Window"

Bookmark and Share

AWT/Swing provides various top level windows such as Window, Frame, Dialog. javafx.stage.Stage is roughly the equivalent for Frame. We can instantiate and show multiple instance of Stage, or we may use Swing windows. But still it may not be convenient and will impact the look and feel of application (especially when deployed as Applet in Browser).

It may not be possible to emulate all features provided by Frame/Dialog (especially Modal-Dialog), but we may implement a CustomNode which has some basic look and functionality. Here is an attempt..

To launch click on above image or

Try it out and let me know feedback..

var dzone_style = ‘2’;

Categories: javafx Tags: ,
  1. Dieter
    December 21, 2009 at 10:36 AM

    Hi Rakesh
    thanks a lot for this real world app.
    I would like to learn, what it is necessary to save record in a database.

  2. December 21, 2009 at 7:51 PM

    @Dieter Thanks! There is nothing specific in JavaFX to connect directly to database. Its same as connecting from Java application. You may refer to
    I have received this query many times before, so I will also provide a simple sample which saves and retrieves records to database (But it will be same as Java code, nothing specific to JavaFX)

  3. rodrigo salado
    December 22, 2009 at 9:16 AM

    a muchisismas gracias todo esto es de mucha ayuda mara mi, thanks 🙂

  4. December 29, 2009 at 1:01 AM

    Hi Rakesh,
    I wast just thinking about implementing this kind of dialog in my javafx application.
    What would be cool imo is to to make the "main" application window darker when the dialog is showing.

  5. December 29, 2009 at 1:56 AM

    @Guido Yes, I agree with you. One way to do this is to introduce another Rectangle (which will fill the entire Scene) with some transparency. Make this Rectangle visible, along with "Window".

  6. December 29, 2009 at 7:48 PM

    @Dieter I have new blog entry, hope this helps..

  7. December 30, 2009 at 11:57 PM

    Thanks for your tips, Rakesh!
    Simple and cool!
    I noticed in your example you do only hide the dialog when it is closed. But this doesn’t remove the dialog from the scenegraph ?

  8. December 31, 2009 at 2:05 AM

    @Guido Good catch.. Yes it will be an issue when there are too many instances of "Window", it needs to be removed from scenegraph to enable garbage collection.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: