Extending builders: StageBuilder
Eva Krejcirova
eva.krejcirova at oracle.com
Wed Jul 11 07:40:27 PDT 2012
Hi All,
this is the first of several emails about adding additional methods to
existing builder classes, this time about StageBuilder class.
First some background: there is an issue (RT-19260) with
StageBuilder.style() method - it only passes the style to the
constructor of Stage, which means that calling applyTo on the builder
doesn't work. The style on Stage can be changed with initStyle, but the
StageBuilder doesn't currently use it. With the new version of the
builder, the builder will call initStyle in applyTo, so the applyTo will
work. However, if called after Stage.show, it will throw an exception -
the same way as the Stage.initStyle does.
Together with this fix, I propose to add following methods to
StageBuilder which also set properties via init... method:
*modality* :
public StageBuilder modality(Modality modality)
- will set modality via initModality
*owner* :
public StageBuilder owner(Window owner)
- will set owner via initOwner
They will behave similar to style() method - i.e. applyTo will throw an
exception when called after Stage.show() and also throw an exception if
called on a primary stage:
StageBuilder builder =
StageBuilder.create().modality(Modality.WINDOW_MODAL);
Stage stage = builder.build(); // this is OK
stage.show();
builder.modality(NONE).applyTo(stage); // this will throw an exception
in applyTo
What do you think?
Thanks,
Eva
More information about the openjfx-dev
mailing list