/** * Construct a new button that can be used to toggle between black and white. * * @param appState Reference to the model, used to change drawing colour. * @param identifier Identifier for this object. */ public ToggleColourButton(ApplicationState appState, String identifier) { super(); this.as = appState; this.identifier = identifier; this.fgCol = Colour.BLACK; this.bgCol = Colour.WHITE; addPressHandler(this); // Set class of button element setStyleName(STYLENAME); // Create element that shows foreground colour, set it up and add it fgColEl = DivElement.as(DOM.createElement("div")); fgColEl.setPropertyString("className", STYLENAME_FG_EL); fgColEl.getStyle().setBackgroundColor(fgCol.toString()); getElement().appendChild(fgColEl); // Create element that shows background colour, set it up and add it bgColEl = DivElement.as(DOM.createElement("div")); bgColEl.setPropertyString("className", STYLENAME_BG_EL); bgColEl.getStyle().setBackgroundColor(bgCol.toString()); getElement().appendChild(bgColEl); // Set the debug ID for the toggle colour button. ensureDebugId("toggleColor"); }