Help Center
Local Navigation
- Creating user interfaces
- Screens
- Touch screen orientation and direction
- Working with the accelerometer of a BlackBerry device
- Types of accelerometer data
- Accelerometer
- Retrieve accelerometer data at specific intervals
- Query the accelerometer when the application is in the foreground
- Query the accelerometer when the application is in the background
- Store accelerometer readings in a buffer
- Retrieve accelerometer readings from a buffer
- Get the time a reading was taken from the accelerometer
- UI components
- Add a UI component to a screen
- Create a dialog box
- Create a bitmap
- Create a button
- Create a list
- Create a drop-down list
- Create a search field
- Create a check box
- Create an option button
- Create a date field
- Creating a text field
- Create a progress indicator
- Create a text label
- Create a list box
- Create a field to display a tree view
- Add a UI component to a screen
- Create a custom field
- Add a menu item to a BlackBerry Device Software application
- Adding a menu item to a BlackBerry Device Software application
- Register a menu item
- Arrange UI components
- Events
- Touch screen events
- Types of touch screen events
- Respond to touch screen events
- Respond to system events while the user touches the screen
- Respond to a user sliding a finger up quickly on the screen
- Respond to a user sliding a finger down quickly on the screen
- Respond to a user sliding a finger to the left quickly on the screen
- Respond to a user sliding a finger to the right quickly on the screen
- Respond to a user clicking the screen
- Respond to a user touching the screen twice quickly
- Respond to a user touching and dragging an item on the screen
- Respond to a user touching the screen lightly
- Respond to a scroll action
- Respond to a user touching the screen in two locations at the same time
- Keyboard on a BlackBerry device with a touch screen
- Spell check
- Accessibility
- Integrating with assistive technology software
- Notifying an assistive technology application when the UI changes
- UI changes that trigger a notification to an assistive technology application
- UI component states and properties
- Provide an assistive technology application with information about a UI change
- Provide an assistive technology application with information about text changes
- Provide an assistive technology application with access to information from a table
- Provide an assistive technology application with access to numeric values
- Enable an assistive technology application to receive notification of UI events
- Storing data
- Creating connections
- Managing applications
- Using custom messages and folders in the message list
- Applications for push content
- Localizing BlackBerry device applications
- Controlling access to APIs and application data
- Testing a BlackBerry device application
- Packaging and distributing a BlackBerry Java Application
- Glossary
- Provide feedback
- Legal notice
BlackBerry Manuals & Help
>
Documentation for Developers
>
Java Development Guides and API Reference
>
Development Guide - BlackBerry Java Development Environment - 4.7.0
Create a field to display a tree view
Use a tree view to display objects, such as a folder
structure, in a hierarchical manner.
A TreeField contains nodes. The highest node is the
root node. A node in the tree can have child nodes under it. A node
that has a child is a parent node.
- Import the following classes:
- Import the net.rim.device.api.ui.component.TreeFieldCallback interface.
- Implement the TreeFieldCallback interface.
- Invoke TreeField.setExpanded() on the TreeField object
to specify whether a folder is collapsible. Create a TreeField object and multiple child nodes to the TreeField object. We then invoke TreeField.setExpanded()
using node4 as a parameter to collapse the folder.
String fieldOne = new String("Main folder"); ... TreeCallback myCallback = new TreeCallback(); TreeField myTree = new TreeField(myCallback, Field.FOCUSABLE); int node1 = myTree.addChildNode(0, fieldOne); int node2 = myTree.addChildNode(0, fieldTwo); int node3 = myTree.addChildNode(node2, fieldThree); int node4 = myTree.addChildNode(node3, fieldFour); ... int node10 = myTree.addChildNode(node1, fieldTen); myTree.setExpanded(node4, false); ... mainScreen.add(myTree); - To repaint a TreeField when a node changes, create a class that implements the TreeFieldCallback interface and implement the TreeFieldCallback.drawTreeItem method. The TreeFieldCallback.drawTreeItem method
uses the cookie for a tree node to draw a String in the location of a node. The TreeFieldCallback.drawTreeItem method
invokes Graphics.drawText() to draw the String.
private class TreeCallback implements TreeFieldCallback { public void drawTreeItem(TreeField _tree, Graphics g, int node, int y, int width, int indent) { String text = (String)_tree.getCookie(node); g.drawText(text, indent, y); } }
Parent topic: UI components