JavaFX – Custom "Window"
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’;
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
@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)
a muchisismas gracias todo esto es de mucha ayuda mara mi, thanks 🙂
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
@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".
@Dieter I have new blog entry, hope this helps..
http://blogs.sun.com/rakeshmenonp/entry/javafx_database_table
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,
@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.