| Author |
Rounded corners on Modal Dialogs
|
Ken Kestner
Greenhorn
Joined: May 08, 2012
Posts: 4
|
|
I'm attempting to emulate a modal dialog with a Stage.
The "body" of the dialog utilizes the following css to have rounded corners at the bottom.
It looks find until it appears over a background that isnt pure white - you can see the white corners of the scene.
The scene has a method "setOpacity", however setting opacity to zero hides the entire scene, even though
I've tried setting the opacity for the individual controls to 1.
Any way to avoid this, or just go with non-rounded corners?
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4167
|
|
JavaFX 1.x or 2.x? To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
And welcome to the Ranch!
edit You could try -fx-background-radius
|
luck, db
There are no new questions, but there may be new answers.
|
 |
John Damien Smith
Ranch Hand
Joined: Jan 26, 2012
Posts: 40
|
|
|
You can find some sample code to achieve a modal dialog with rounded corners in JavaFX 2.1 here => https://gist.github.com/1887631 "JavaFX Modal Confirm Dialog Box Example"
|
 |
Ken Kestner
Greenhorn
Joined: May 08, 2012
Posts: 4
|
|
John Damien Smith wrote:You can find some sample code to achieve a modal dialog with rounded corners in JavaFX 2.1 here => https://gist.github.com/1887631 "JavaFX Modal Confirm Dialog Box Example"
That did the trick, changing from StageStyle.UNDECORATED to StageStyle.TRANSPARENT appeared to work - although I cant figure out why I'm not getting the standard title bar icons now.
Getting some jaggies around the edges, but I can live with it.
Thanks.
Edit:
Is there any way to move the transparency and opacity settings to my CSS file? I'd prefer to have zero
style settings in my code.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4167
|
|
|
If it's not in the JavaFX CSS Reference Guide then, no.
|
 |
John Damien Smith
Ranch Hand
Joined: Jan 26, 2012
Posts: 40
|
|
Is there any way to move the transparency and opacity settings to my CSS file?
I updated the example https://gist.github.com/1887631 to use style classes rather than inline styles and method calls.
Getting some jaggies around the edges
The edges are smooth and anti-aliased (at least on my machine), could be that your eyes are more sensitive to the anti-aliasing algorithm or you are running off different hardware or system software which causes the jaggies for you.
changing from StageStyle.UNDECORATED to StageStyle.TRANSPARENT appeared to work - although I cant figure out why I'm not getting the standard title bar icons now.
From the documentation: http://docs.oracle.com/javafx/2/api/javafx/stage/StageStyle.html#TRANSPARENT
"Defines a Stage style with a transparent background and no decorations."
If you want decorations like a title bar or icons, you will need to create new nodes in the dialog which render these things and write further code to setup appropriate event handlers for them (see the Ensemble application for an example of how to do this: http://www.oracle.com/technetwork/java/javafx/samples/index.html).
|
 |
 |
|
|
subject: Rounded corners on Modal Dialogs
|
|
|