fxface :: Dialog class :: abstract
In the previous article I talked about the fxface Window for Potomac, in this article I’ll explore the Dialog class.
The Dialog inherits it’s template methods from the Window, the main method for the UI is createContents(). The createContents() method is where it all happens for the controls of the Dialog.
Up in the Window class this method is abstract and will get called from the Window.create() method. This allows subclasses to not concern themselves with when or how the controls get created, the Dialog just overrides createContents() and creates it’s ui components using the parent ui component passed to the method.
Dialog Content
The Dialog’s contents essentially add up to the following structure;
<VBox id="root">
<VBox id="dialogArea">
</VBox>
<HRule id="dialogAreaSeparator"/>
<HBox id="buttonBar">
<Spacer/>
<Button id="okButton"/>
<Button id="cancelButton"/>
</HBox>
</VBox>
createContents()creates the first box which is the root child of theIShell.createDialogArea()creates thedialogArea, this box that will hold subclass’s content.createDialogAreaSeparator()creates theHRulethat separates thedialogAreafrom thebuttonBar.createButtonBar()creates thebuttonBarwith the spacer,okButtonandcancelButton.
The image below shows how this all pans out during runtime. Ignore the icons and text you see, Dialog is really quite abstract, the text comes from the IconAndMessageDialog implementation.

Button handling
The Dialog adds necessary handlers to the ok and cancel buttons. The handlers themselves are private but, they call two overridable protected methods, okPressed() and cancelPressed().
The cancelPressed() method in Dialog will call the dialog’s close() method if not overridden in a subclass. The okPressed() method is abstract and is meant to be implemented in the subclass.
Conclusion
This wraps up this article of fxface, remember the Dialog should be an abstract class, it just sets up some more template methods dealing with the ui, adds an area for subclasses to add content, adds an ok and cancel button.
Peace,
Mike