Java Doc for List.java in  » 6.0-JDK-Modules » j2me » javax » microedition » lcdui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » javax.microedition.lcdui 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.microedition.lcdui.Displayable
      javax.microedition.lcdui.Screen
         javax.microedition.lcdui.List

All known Subclasses:   com.sun.midp.appmanager.MIDletSwitcher,
List
public class List extends Screen implements Choice(Code)
A Screen containing list of choices. Most of its behavior is common with class ChoiceGroup ChoiceGroup , and their common API. The different List types in particular, are defined in interface ChoiceChoice . When a List is present on the display, the user can interact with it by selecting elements and possibly by traversing and scrolling among them. Traversing and scrolling operations do not cause application-visible events. The system notifies the application only when a CommandCommand is invoked by notifying its CommandListener . The List class also supports a select command that may be invoked specially depending upon the capabilities of the device.

The notion of a select operation on a List element is central to the user's interaction with the List. On devices that have a dedicated hardware "select" or "go" key, the select operation is implemented with that key. Devices that do not have a dedicated key must provide another means to do the select operation, for example, using a soft key. The behavior of the select operation within the different types of lists is described in the following sections.

List objects may be created with Choice types of Choice.EXCLUSIVE , Choice.MULTIPLE , and Choice.IMPLICIT . The Choice type Choice.POPUP is not allowed on List objects.

Selection in EXCLUSIVE and MULTIPLE Lists

The select operation is not associated with a Command object, so the application has no means of setting a label for it or being notified when the operation is performed. In Lists of type EXCLUSIVE, the select operation selects the target element and deselects the previously selected element. In Lists of type MULTIPLE, the select operation toggles the selected state of the target element, leaving the selected state of other elements unchanged. Devices that implement the select operation using a soft key will need to provide a label for it. The label should be something similar to "Select" for Lists of type EXCLUSIVE, and it should be something similar to "Mark" or "Unmark" for Lists of type MULTIPLE.

Selection in IMPLICIT Lists

The select operation is associated with a Command object referred to as the select command. When the user performs the select operation, the system will invoke the select command by notifying the List's CommandListener CommandListener . The default select command is the system-provided command SELECT_COMMAND. The select command may be modified by the application through use of the List.setSelectCommand(Command command) setSelectCommand method. Devices that implement the select operation using a soft key will use the label from the select command. If the select command is SELECT_COMMAND, the device may choose to provide its own label instead of using the label attribute of SELECT_COMMAND. Applications should generally provide their own select command to replace SELECT_COMMAND. This allows applications to provide a meaningful label, instead of relying on the one provided by the system for SELECT_COMMAND. The implementation must not invoke the select command if there are no elements in the List, because if the List is empty the selection does not exist. In this case the implementation should remove or disable the select command if it would appear explicitly on a soft button or in a menu. Other commands can be invoked normally when the List is empty.

Use of IMPLICIT Lists

IMPLICIT Lists can be used to construct menus by providing operations as List elements. The application provides a Command that is used to select a List element and then defines this Command to be used as the select command. The application must also register a CommandListener that is called when the user selects or activates the Command:


 String[] elements = { ... }; //Menu items as List elements
 List menuList = new List("Menu", List.IMPLICIT, elements, null);
 Command selectCommand = new Command("Open", Command.ITEM, 1);
 menuList.setSelectCommand(selectCommand);
 menuList.setCommandListener(...);     

The listener can query the List to determine which element is selected and then perform the corresponding action. Note that setting a command as the select command adds it to the List as a side effect.

The select command should be considered as a default operation that takes place when a select key is pressed. For example, a List displaying email headers might have three operations: read, reply, and delete. Read is considered to be the default operation.


 List list = new List("Email", List.IMPLICIT, headers);
 readCommand = new Command("Read", Command.ITEM, 1);
 replyCommand = new Command("Reply", Command.ITEM, 2);
 deleteCommand = new Command("Delete", Command.ITEM, 3);
 list.setSelectCommand(readCommand);
 list.addCommand(replyCommand);
 list.addCommand(deleteCommand);
 list.setCommandListener(...);     

On a device with a dedicated select key, pressing this key will invoke readCommand. On a device without a select key, the user is still able to invoke the read command, since it is also provided as an ordinary Command.

It should be noted that this kind of default operation must be used carefully, and the usability of the resulting user interface must always kept in mind. The default operation should always be the most intuitive operation on a particular List.


since:
   MIDP 1.0


Field Summary
final public static  CommandSELECT_COMMAND
     The default select command for IMPLICIT Lists. Applications using an IMPLICIT List should set their own select command using List.setSelectCommand(Command command) setSelectCommand .

The field values of SELECT_COMMAND are:
- label = "" (an empty string)
- type = SCREEN
- priority = 0

(It would be more appropriate if the type were ITEM, but the type of SCREEN is retained for historical purposes.)

The application should not use these values for recognizing the SELECT_COMMAND.

 ChoiceGroupcg
    
 FormLFlistLF
    
 CommandselectCommand
     This is an internal Command which represents the callback to a selection event of an IMPLICIT list.

Constructor Summary
public  List(String title, int listType)
     Creates a new, empty List, specifying its title and the type of the list.
public  List(String title, int listType, String[] stringElements, Image[] imageElements)
     Creates a new List, specifying its title, the type of the List, and an array of Strings and Images to be used as its initial contents.

The stringElements array must be non-null and every array element must also be non-null.


Method Summary
public  intappend(String stringPart, Image imagePart)
     Appends an element to the List.
public  voiddelete(int elementNum)
     Deletes the element referenced by elementNum.
public  voiddeleteAll()
     Deletes all elements from this List.
public  intgetFitPolicy()
     Gets the application's preferred policy for fitting Choice element contents to the available screen space.
public  FontgetFont(int elementNum)
     Gets the application's preferred font for rendering the specified element of this Choice.
public  ImagegetImage(int elementNum)
     Gets the Image part of the element referenced by elementNum.
public  intgetSelectedFlags(boolean[] selectedArray_return)
     Queries the state of a List and returns the state of all elements in the boolean array selectedArray_return.
public  intgetSelectedIndex()
     Returns the index number of an element in the List that is selected.
public  StringgetString(int elementNum)
     Gets the String part of the element referenced by elementNum.
public  voidinsert(int elementNum, String stringPart, Image imagePart)
     Inserts an element into the List just prior to the element specified.
public  booleanisSelected(int elementNum)
     Gets a boolean value indicating whether this element is selected.
public  voidremoveCommand(Command cmd)
     The same as Displayable.removeCommand Displayable.removeCommand but with the following additional semantics.
public  voidset(int elementNum, String stringPart, Image imagePart)
     Sets the String and Image parts of the element referenced by elementNum, replacing the previous contents of the element.
public  voidsetFitPolicy(int fitPolicy)
     Sets the application's preferred policy for fitting Choice element contents to the available screen space.
public  voidsetFont(int elementNum, Font font)
     Sets the application's preferred font for rendering the specified element of this Choice. An element's font is a hint, and the implementation may disregard the application's preferred font.

The elementNum parameter must be within the range [0..size()-1], inclusive.

The font parameter must be a valid Font object or null.

public  voidsetSelectCommand(Command command)
     Sets the Command to be used for an IMPLICIT List selection action. By default, an implicit selection of a List will result in the predefined List.SELECT_COMMAND being used.
public  voidsetSelectedFlags(boolean[] selectedArray)
     Sets the selected state of all elements of the List.
public  voidsetSelectedIndex(int elementNum, boolean selected)
     Sets the selected state of an element.
public  intsize()
     Gets the number of elements in the List.

Field Detail
SELECT_COMMAND
final public static Command SELECT_COMMAND(Code)
The default select command for IMPLICIT Lists. Applications using an IMPLICIT List should set their own select command using List.setSelectCommand(Command command) setSelectCommand .

The field values of SELECT_COMMAND are:
- label = "" (an empty string)
- type = SCREEN
- priority = 0

(It would be more appropriate if the type were ITEM, but the type of SCREEN is retained for historical purposes.)

The application should not use these values for recognizing the SELECT_COMMAND. Instead, object identities of the Command and Displayable (List) should be used.

SELECT_COMMAND is treated as an ordinary Command if it is used with other Displayable types.




cg
ChoiceGroup cg(Code)
An internal choicegroup to handle the selections



listLF
FormLF listLF(Code)
Look & Feel object associated with this List



selectCommand
Command selectCommand(Code)
This is an internal Command which represents the callback to a selection event of an IMPLICIT list. By default, this command is the predefined List.SELECT_COMMAND. This can be overridden however using the setSelectCommand().




Constructor Detail
List
public List(String title, int listType)(Code)
Creates a new, empty List, specifying its title and the type of the list.
Parameters:
  title - the screen's title (see Displayable Displayable)
Parameters:
  listType - one of IMPLICIT, EXCLUSIVE,or MULTIPLE
throws:
  IllegalArgumentException - if listType is notone ofIMPLICIT,EXCLUSIVE, or MULTIPLE
See Also:   Choice



List
public List(String title, int listType, String[] stringElements, Image[] imageElements)(Code)
Creates a new List, specifying its title, the type of the List, and an array of Strings and Images to be used as its initial contents.

The stringElements array must be non-null and every array element must also be non-null. The length of the stringElements array determines the number of elements in the List. The imageElements array may be null to indicate that the List elements have no images. If the imageElements array is non-null, it must be the same length as the stringElements array. Individual elements of the imageElements array may be null in order to indicate the absence of an image for the corresponding List element. Non-null elements of the imageElements array may refer to mutable or immutable images.


Parameters:
  title - the screen's title (see Displayable Displayable)
Parameters:
  listType - one of IMPLICIT, EXCLUSIVE,or MULTIPLE
Parameters:
  stringElements - set of strings specifying the string parts of theList elements
Parameters:
  imageElements - set of images specifying the image parts ofthe List elements
throws:
  NullPointerException - if stringElements isnull
throws:
  NullPointerException - if the stringElementsarray contains any null elements
throws:
  IllegalArgumentException - if the imageElementsarray is non-nulland has a different length from the stringElements array
throws:
  IllegalArgumentException - if listType is not one of IMPLICIT,EXCLUSIVE, or MULTIPLE
See Also:   Choice.EXCLUSIVE
See Also:   Choice.MULTIPLE
See Also:   Choice.IMPLICIT




Method Detail
append
public int append(String stringPart, Image imagePart)(Code)
Appends an element to the List.
Parameters:
  stringPart - the string part of the element to be added
Parameters:
  imagePart - the image part of the element to be added, ornull if there is no image part the assigned index of the element
throws:
  NullPointerException - if stringPart isnull



delete
public void delete(int elementNum)(Code)
Deletes the element referenced by elementNum.
Parameters:
  elementNum - the index of the element to be deleted
throws:
  IndexOutOfBoundsException - if elementNum is invalid



deleteAll
public void deleteAll()(Code)
Deletes all elements from this List.



getFitPolicy
public int getFitPolicy()(Code)
Gets the application's preferred policy for fitting Choice element contents to the available screen space. The value returned is the policy that had been set by the application, even if that value had been disregarded by the implementation. one of List.TEXT_WRAP_DEFAULT, List.TEXT_WRAP_ON, orList.TEXT_WRAP_OFF
See Also:   List.setFitPolicy



getFont
public Font getFont(int elementNum)(Code)
Gets the application's preferred font for rendering the specified element of this Choice. The value returned is the font that had been set by the application, even if that value had been disregarded by the implementation. If no font had been set by the application, or if the application explicitly set the font to null, the value is the default font chosen by the implementation.

The elementNum parameter must be within the range [0..size()-1], inclusive.


Parameters:
  elementNum - the index of the element, starting from zero the preferred font to use to render the element
throws:
  IndexOutOfBoundsException - if elementNum is invalid
See Also:   List.setFont(int elementNum,Font font)



getImage
public Image getImage(int elementNum)(Code)
Gets the Image part of the element referenced by elementNum.
Parameters:
  elementNum - the number of the element to be queried the image part of the element, or nullif there is no image
throws:
  IndexOutOfBoundsException - if elementNum is invalid
See Also:   List.getString(int)



getSelectedFlags
public int getSelectedFlags(boolean[] selectedArray_return)(Code)
Queries the state of a List and returns the state of all elements in the boolean array selectedArray_return.
Parameters:
  selectedArray_return - array to contain the results the number of selected elements in the Choice
throws:
  IllegalArgumentException - if selectedArray_returnis shorter than the size of the List
throws:
  NullPointerException - if selectedArray_return is null
See Also:   List.setSelectedFlags



getSelectedIndex
public int getSelectedIndex()(Code)
Returns the index number of an element in the List that is selected. index of selected element, or -1 if none
See Also:   List.setSelectedIndex



getString
public String getString(int elementNum)(Code)
Gets the String part of the element referenced by elementNum.
Parameters:
  elementNum - the index of the element to be queried the string part of the element
throws:
  IndexOutOfBoundsException - if elementNum is invalid
See Also:   List.getImage(int)



insert
public void insert(int elementNum, String stringPart, Image imagePart)(Code)
Inserts an element into the List just prior to the element specified.
Parameters:
  elementNum - the index of the element where insertion is to occur
Parameters:
  stringPart - the string part of the element to be inserted
Parameters:
  imagePart - the image part of the element to be inserted,or null if there is no image part
throws:
  IndexOutOfBoundsException - if elementNum is invalid
throws:
  NullPointerException - if stringPart isnull



isSelected
public boolean isSelected(int elementNum)(Code)
Gets a boolean value indicating whether this element is selected.
Parameters:
  elementNum - index to element to be queried selection state of the element
throws:
  IndexOutOfBoundsException - if elementNum is invalid



removeCommand
public void removeCommand(Command cmd)(Code)
The same as Displayable.removeCommand Displayable.removeCommand but with the following additional semantics.

If the command to be removed happens to be the select command, the List is set to have no select command, and the command is removed from the List.

The following code:


 // Command c is the select command on List list    
 list.removeCommand(c);     

is equivalent to the following code:


 // Command c is the select command on List list    
 list.setSelectCommand(null);    
 list.removeCommand(c);     

Parameters:
  cmd - the command to be removed



set
public void set(int elementNum, String stringPart, Image imagePart)(Code)
Sets the String and Image parts of the element referenced by elementNum, replacing the previous contents of the element.
Parameters:
  elementNum - the index of the element to be set
Parameters:
  stringPart - the string part of the new element
Parameters:
  imagePart - the image part of the element, or nullif there is no image part
throws:
  IndexOutOfBoundsException - if elementNum is invalid
throws:
  NullPointerException - if stringPart isnull



setFitPolicy
public void setFitPolicy(int fitPolicy)(Code)
Sets the application's preferred policy for fitting Choice element contents to the available screen space. The set policy applies for all elements of the Choice object. Valid values are List.TEXT_WRAP_DEFAULT , List.TEXT_WRAP_ON , and List.TEXT_WRAP_OFF . Fit policy is a hint, and the implementation may disregard the application's preferred policy.
Parameters:
  fitPolicy - preferred content fit policy for choice elements
throws:
  IllegalArgumentException - if fitPolicy is invalid
See Also:   List.getFitPolicy



setFont
public void setFont(int elementNum, Font font)(Code)
Sets the application's preferred font for rendering the specified element of this Choice. An element's font is a hint, and the implementation may disregard the application's preferred font.

The elementNum parameter must be within the range [0..size()-1], inclusive.

The font parameter must be a valid Font object or null. If the font parameter is null, the implementation must use its default font to render the element.


Parameters:
  elementNum - the index of the element, starting from zero
Parameters:
  font - the preferred font to use to render the element
throws:
  IndexOutOfBoundsException - if elementNum is invalid
See Also:   List.getFont



setSelectCommand
public void setSelectCommand(Command command)(Code)
Sets the Command to be used for an IMPLICIT List selection action. By default, an implicit selection of a List will result in the predefined List.SELECT_COMMAND being used. This behavior may be overridden by calling the List.setSelectCommand() method with an appropriate parameter value. If a null reference is passed, this indicates that no "select" action is appropriate for the contents of this List.

If a reference to a command object is passed, and it is not the special command List.SELECT_COMMAND, and it is not currently present on this List object, the command object is added to this List as if addCommand(command) had been called prior to the command being made the select command. This indicates that this command is to be invoked when the user performs the "select" on an element of this List.

The select command should have a command type of ITEM to indicate that it operates on the currently selected object. It is not an error if the command is of some other type. (List.SELECT_COMMAND has a type of SCREEN for historical purposes.) For purposes of presentation and placement within its user interface, the implementation is allowed to treat the select command as if it were of type ITEM.

If the select command is later removed from the List with removeCommand(), the List is set to have no select command as if List.setSelectCommand(null) had been called.

The default behavior can be reestablished explicitly by calling setSelectCommand() with an argument of List.SELECT_COMMAND.

This method has no effect if the type of the List is not IMPLICIT.


Parameters:
  command - the command to be used for an IMPLICIT listselection action, or null if there is none



setSelectedFlags
public void setSelectedFlags(boolean[] selectedArray)(Code)
Sets the selected state of all elements of the List.
Parameters:
  selectedArray - an array in which the method collectthe selection status
throws:
  IllegalArgumentException - if selectedArray isshorter than the size of the List
throws:
  NullPointerException - if selectedArray isnull
See Also:   List.getSelectedFlags



setSelectedIndex
public void setSelectedIndex(int elementNum, boolean selected)(Code)
Sets the selected state of an element.
Parameters:
  elementNum - the index of the element, starting from zero
Parameters:
  selected - the state of the element, where true meansselected and false means not selected
throws:
  IndexOutOfBoundsException - if elementNum is invalid
See Also:   List.getSelectedIndex



size
public int size()(Code)
Gets the number of elements in the List. the number of elements in the List




Fields inherited from javax.microedition.lcdui.Displayable
Command commands(Code)(Java Doc)
DisplayableLF displayableLF(Code)(Java Doc)
boolean isInFullScreenMode(Code)(Java Doc)
boolean isRotated(Code)(Java Doc)
CommandListener listener(Code)(Java Doc)
int numCommands(Code)(Java Doc)
Ticker ticker(Code)(Java Doc)
String title(Code)(Java Doc)

Methods inherited from javax.microedition.lcdui.Displayable
public void addCommand(Command cmd)(Code)(Java Doc)
int addCommandImpl(Command cmd)(Code)(Java Doc)
public int getHeight()(Code)(Java Doc)
DisplayableLF getLF()(Code)(Java Doc)
public Ticker getTicker()(Code)(Java Doc)
public String getTitle()(Code)(Java Doc)
public int getWidth()(Code)(Java Doc)
public boolean isShown()(Code)(Java Doc)
void itemStateChanged(Item src)(Code)(Java Doc)
public void removeCommand(Command cmd)(Code)(Java Doc)
int removeCommandImpl(Command cmd)(Code)(Java Doc)
public void setCommandListener(CommandListener l)(Code)(Java Doc)
public void setTicker(Ticker ticker)(Code)(Java Doc)
public void setTitle(String s)(Code)(Java Doc)
protected void sizeChanged(int w, int h)(Code)(Java Doc)
void uCallItemStateChanged(Item src)(Code)(Java Doc)

Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.