Using the new font formatting GUI

Previous chapter described FontPanel as SimplyHTML's GUI to set most relevant font and font style settings at once. To actually use class FontPanel two additional classes are required. First of all, a dialog is needed to present a FontPanel to the user. As well an action to invoke respective dialog must be created.

Class FontDialog

Class FontDialog simply wraps class FontPanel into a JDialog and creates all methods necessary to control the dialog such as closing the dialog with 'OK', cancelling the dialog etc.

In its constructor FontDialog expects an AttributeSet which is routed on to FontPanel for display and manipulation. Once the dialog is closed by pressing the 'OK' button, method getAttributes returns the AttributeSet from method getAttributes of class FontPanel. Method getResult returns the information whether the dialog was closed with the 'OK' or the 'Cancel' button.

Action FontAction

With class FontAction all previously described font functionality is 'plugged' into SimplyHTML's mechanism to make functions available on the GUI. Its method actionPerformed creates an instance of class FontDialog and applies font changes from FontDialog to a document. FontAction is added to the commands Hashtable of FrmMain through method initActions and its name is reflected in the action name constants of FrmMain ensuring proper usage during dynamic menu creation.

To always reflect proper state to components bound to FontAction, it implements interface SHTMLAction with method update.