📄 list.java
字号:
if (!(listType == IMPLICIT || listType == EXCLUSIVE || listType == MULTIPLE)) { throw new IllegalArgumentException(); } synchronized (Display.LCDUILock) { cg = new ChoiceGroup(null, listType, stringElements, imageElements, true); cg.isList = true; form = new Form(title); form.paintDelegate = this; form.append(cg); } } // public methods // /** * Sets a ticker for use with this <code>Displayable</code>, * replacing any * previous ticker. * If <code>null</code>, removes the ticker object * from this <code>Displayable</code>. The same ticker may be shared by * several <code>Displayable</code> * objects within an application. This is done by calling * <code>setTicker()</code> * with the same <code>Ticker</code> object on several * different <code>Displayable</code> objects. * If the <code>Displayable</code> is actually visible on the display, * the implementation should update * the display as soon as it is feasible to do so. * * <p>The existence of a ticker may affect the size * of the area available for <code>Displayable's</code> contents. * If the application adds, removes, or sets the ticker text at runtime, * this can dynamically change the size of the content area. * This is most important to be aware of when using the * <code>Canvas</code> class. * * @param ticker the ticker object used on this screen * @since MIDP 2.0 * @see #getTicker */ public void setTicker(Ticker ticker) { super.setTicker(ticker); // We override this method from Displayable to set the ticker // on our internal Form which is doing all our rendering form.setTicker(ticker); } /** * Sets the title of the <code>Displayable</code>. If * <code>null</code> is given, * removes the title. * * <P>If the <code>Displayable</code> is actually visible on * the display, * the implementation should update * the display as soon as it is feasible to do so.</P> * * <P>The existence of a title may affect the size * of the area available for <code>Displayable</code> content. * If the application adds, removes, or sets the title text at runtime, * this can dynamically change the size of the content area. * This is most important to be aware of when using the * <code>Canvas</code> class.</p> * * @param s the new title, or <code>null</code> for no title * @since MIDP 2.0 * @see #getTitle */ public void setTitle(String s) { super.setTitle(s); // We override this method from Displayable to set the title // on our internal Form which is doing all our rendering form.setTitle(s); } /** * Gets the number of elements in the <code>List</code>. * @return the number of elements in the <code>List</code> */ public int size() { return cg.size(); } /** * Gets the <code>String</code> part of the element referenced by * <code>elementNum</code>. * * @param elementNum the index of the element to be queried * @return the string part of the element * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid * @see #getImage(int) */ public String getString(int elementNum) { return cg.getString(elementNum); } /** * Gets the <code>Image</code> part of the element referenced by * <code>elementNum</code>. * * @param elementNum the number of the element to be queried * @return the image part of the element, or <code>null</code> * if there is no image * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid * @see #getString(int) */ public Image getImage(int elementNum) { return cg.getImage(elementNum); } /** * Appends an element to the <code>List</code>. * * @param stringPart the string part of the element to be added * @param imagePart the image part of the element to be added, or * <code>null</code> if there is no image part * @return the assigned index of the element * @throws NullPointerException if <code>stringPart</code> is * <code>null</code> */ public int append(String stringPart, Image imagePart) { return cg.append(stringPart, imagePart); } /** * Inserts an element into the <code>List</code> just prior to * the element specified. * * @param elementNum the index of the element where insertion is to occur * @param stringPart the string part of the element to be inserted * @param imagePart the image part of the element to be inserted, * or <code>null</code> if there is no image part * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid * @throws NullPointerException if <code>stringPart</code> is * <code>null</code> */ public void insert(int elementNum, String stringPart, Image imagePart) { cg.insert(elementNum, stringPart, imagePart); } /** * Deletes the element referenced by <code>elementNum</code>. * * @param elementNum the index of the element to be deleted * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid */ public void delete(int elementNum) { cg.delete(elementNum); } /** * Deletes all elements from this List. */ public void deleteAll() { cg.deleteAll(); } /** * Sets the <code>String</code> and <code>Image</code> parts of the * element referenced by <code>elementNum</code>, * replacing the previous contents of the element. * * @param elementNum the index of the element to be set * @param stringPart the string part of the new element * @param imagePart the image part of the element, or <code>null</code> * if there is no image part * * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid * @throws NullPointerException if <code>stringPart</code> is * <code>null</code> */ public void set(int elementNum, String stringPart, Image imagePart) { cg.set(elementNum, stringPart, imagePart); } /** * Gets a boolean value indicating whether this element is selected. * * @param elementNum index to element to be queried * * @return selection state of the element * * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid */ public boolean isSelected(int elementNum) { return cg.isSelected(elementNum); } /** * Returns the index number of an element in the <code>List</code> * that is selected. * * @return index of selected element, or <code>-1</code> if none * @see #setSelectedIndex */ public int getSelectedIndex() { return cg.getSelectedIndex(); } /** * Queries the state of a <code>List</code> and returns the * state of all elements * in the * boolean array * <code>selectedArray_return</code>. * * @param selectedArray_return array to contain the results * * @return the number of selected elements in the <code>Choice</code> * * @throws IllegalArgumentException if <code>selectedArray_return</code> * is shorter than the size of the List * @throws NullPointerException if <code>selectedArray_return</code> * is <code>null</code> * @see #setSelectedFlags */ public int getSelectedFlags(boolean[] selectedArray_return) { return cg.getSelectedFlags(selectedArray_return); } /** * Sets the selected state of an element. * * @param elementNum the index of the element, starting from zero * @param selected the state of the element, where <code>true</code> means * selected and <code>false</code> means not selected * @throws IndexOutOfBoundsException if <code>elementNum</code> is invalid * @see #getSelectedIndex */ public void setSelectedIndex(int elementNum, boolean selected) { cg.setSelectedIndex(elementNum, selected); } /** * Sets the selected state of all elements of the <code>List</code>. * * @param selectedArray an array in which the method collect * the selection status * @throws IllegalArgumentException if <code>selectedArray</code> is * shorter than the size of the <code>List</code> * @throws NullPointerException if <code>selectedArray</code> is * <code>null</code> * @see #getSelectedFlags */ public void setSelectedFlags(boolean[] selectedArray) { cg.setSelectedFlags(selectedArray); } /** * The same as {@link Displayable#removeCommand Displayable.removeCommand} * but with the following additional semantics. * * <p>If the command to be removed happens to be the select command, the * <code>List</code> is set to have no select command, and the command is * removed from the <code>List</code>.</p> * * <p>The following code: </P> * <TABLE BORDER="2"> * <TR> * <TD ROWSPAN="1" COLSPAN="1"> * <pre><code> * // Command c is the select command on List list * list.removeCommand(c); </code></pre> * </TD> * </TR> * </TABLE> * <P> * is equivalent to the following code: </P> * <TABLE BORDER="2"> * <TR> * <TD ROWSPAN="1" COLSPAN="1">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -