The Flow Designer visually represents the different paths that can be taken between your application's different screens. Using this view, you can add or remove screens, as well as the transitions between them. It is also possible to modify the properties of the screens and transitions. Figure 14-11. Action dialog box
The Flow Designer is composed of four parts: the component palette, the Inspector, the Flow Design panel, and a property sheet. Following is a quick overview of these panels, as well as their respective capabilities. Component PaletteThe component palette (shown in Figure 14-12) contains groupings of all Java objects that can be added to your application with the designer. If an object does not exist in the component palette, it cannot be added to the application using the Flow Designer. Figure 14-12. Component palette
The following categories are used:
Special ComponentsThe Visual Designer provides certain special components that can be used when creating applications and the standard MIDP components are not enough. Splash ScreenSplash screen is a simple component that can be used to present logos during application startup cycle, for example. To create a splash screen, simply drag the SplashScreen component onto the Flow Design work space. Select it using the mouse and use the property editor to customize it. Image, Text, Text Font, and Timeout are amongst the most commonly used attributes. TableThe table component is a custom component based on the MIDP CustomItem class and can be used to present data in a formatted table. The component can be used only for viewing data and it might not work properly with all real devices, as it is not fragmented and implementations of the CustomItem vary from device to device. In order to use this component, you must first create a form and then add the Table component to the form by dragging it from the Palette window onto its icon. Using the Property Editor, you can set attributes such as fonts, preferred size, and title. You populate the table with data using your own custom code. Wait ScreenThe WaitScreen is a non-visual component that can be used as a junction box that splits the program flow. If the execute() method implemented in the get_simpleCancellableTask() method throws an exception, the program will follow the Failure route; otherwise, it will follow the Success route. The execute() method's code runs in a separate thread so the application does not freeze in the case that the task takes too long to complete. To use the Flow Designer to create a program with a WaitScreen component as a junction:
String action=get_choiceGroup1().getString(get_choiceGroup1().getSelectedIndex( )); if (action.equals("Fail")) throw new Exception("Failure"); When you run the program using your favorite emulator, you use the ChoiceGroup item to select an action, and then based on that, you will get a Fail or Pass Alert. InspectorThe Inspector (shown in Figure 14-14) displays all objects that have been added to the visual design in a tree formation. The root node of the tree is the MIDP Design node with child nodes for Screens, Commands, and Resources. Any objects from these groups that have been added to the design appear under their respective group header nodes. Figure 14-14. Inspector
If a node represents an object that can have action commands associated with it, it has an Assigned Commands group node containing each assigned action. Similarly, objects that support elements or items contain an Elements or Items group. Selected objects in the Inspector are highlighted in Screen Designer or Flow Designer view (if the object appears in the currently active design view). Additionally, the object's properties are displayed in Property Sheet view. Right-clicking a component node opens a menu consisting of standard node commands (Rename, Delete, Move Up, Move Down, and Properties). Right-clicking the Action Command, Elements, or Items node opens a menu containing actions for adding a new node to the list or changing the order of the list. Property SheetA standard property sheet is visible when the designer is open. This property sheet shows the editable properties for any object selected in Designer or Inspector view. The property sheet contains all MIDP2 properties for the selected object. Additionally, there are some items specific to the source code and components, as described here:
Flow DesignerThe main screen of the Flow Designer uses drag-and-drop to add and connect components in the MIDlet. All designs contain a Mobile Device element that represents the MIDlet's start point. Displayable components (screens) can be dragged from the Palette window and dropped onto the Design screen. After a screen has been added, appropriate commands, elements, items, and resources can be added to it by dragging the object from the Palette window and dropping it on the screen. Transition sources are displayed on the right side of the component to which they are attached. These are used to create transitions to different screens by selecting the transition source and dragging to the target screen. The connection is visualized in the design as a line. Transitions can also be selected. Doing so paints the transition in a different color and displays the transition sources' properties in the property sheet. Selecting a screen node highlights all transitions to and from that screen in a different color. Double-clicking a screen opens it in Screen Design view. ToolbarThe toolbar of the Flow Designer has four items:
|