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’;

Advertisements

About Rakesh Menon
-

8 Responses to JavaFX – Custom “Window”

  1. Dieter says:

    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.
    Dieter

  2. Rakesh Menon says:

    @Dieter Thanks! There is nothing specific in JavaFX to connect directly to database. Its same as connecting from Java application. You may refer to
    http://jfxstudio.wordpress.com/2009/02/22/javafx-sql-server/
    http://jfxstudio.wordpress.com/2009/03/03/the-graphic-database-front-end/
    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 says:

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

  4. Guido says:

    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.
    Guido

  5. Rakesh Menon says:

    @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. Guido says:

    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 ?
    BR,

  7. Rakesh Menon says:

    @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.

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: