Previous | Next |
Tiles.java
The Tiles class is the controller for Tiles components. It creates the model, the view, and the GUIHandler, and gets the string resources for the component specified by the TilesResources class. The controller also constructs and maintains a GUIHander that manages the user interface for the component.
Create a Tiles component | public class Tiles extends ComponentController { public Tiles() { try { setResourceBundle(ResourceBundle.getBundle("tiles.TilesResources")); } catch (MissingResourceException e) { new ExceptionDialog(null, "Can't find resource file", e); } setModel(new TileModel()); setGUIHandler(new TilesGUIHandler(this)); setModelSelection(new TileSelection(this, (TileModel)getModel())); setView(new TileView()); }public static void main(String args[]) { setApplicationMain(true); new Tiles(); } |
Helper methods for handling actions associated with Tiles menu items and tool buttons | public void createRock() { ((TilesGUIHandler)getGUIHandler()).createTile(Tile.kRock); }public void createPaper() { ((TilesGUIHandler)getGUIHandler()).createTile(Tile.kPaper); }public void createScissor() { ((TilesGUIHandler)getGUIHandler()).createTile(Tile.kScissor); }public void undo() { ((TilesGUIHandler)getGUIHandler()).undo(); }public void redo() { ((TilesGUIHandler)getGUIHandler()).redo(); } } |
Classes for Tiles sample:
Previous | Next |
Copyright ©
Taligent, Inc. 1996 - 1997.
Copyright © IBM Corporation 1996 - 1997.
All Rights Reserved.