?? listscreen.java
字號:
package com.jmobilecore.ui.core;
import java.util.Enumeration;
/**
* A <code>ListScreen</code> is object inherited from <code>ScreenCanvas</code>
* which allows select item from the list of items.
* Each item in the list must belong to the <code>ListComponent</code>
* class. It can be an instance of <code>ListComponent</code> or subclasses.
*
* @author Greg Gridin
*/
public class ListScreen extends ScreenCanvas {
/**
* Constructs a new list with the specified title.
* Soft keys can be added later
* @param title the list's title (on screen's top)
*/
public ListScreen(Label title) {
super(title);
}
/**
* Creates a new <code>ListScreen</code> instance with specified
* container for soft keys
*
* @param title Title for current screen
* @param softKeyBar Container for soft keys for current screen
*/
public ListScreen(Label title, SoftKeyBar softKeyBar) {
super(title, softKeyBar);
}
/**
* Constructs a new list with the specified title and softkeys.
* @param title the list's title (on screen's top)
* @param leftAction
* @param rightAction
*/
public ListScreen(Label title, SoftKey leftAction, SoftKey rightAction) {
super(title);
softKeyBar.setSoftKey(leftAction, SoftKey.LEFT);
softKeyBar.setSoftKey(rightAction, SoftKey.RIGHT);
}
/**
* Gets the selected item on this list form.
*
* @return the selected item on the list form, or null if no item is selected
*/
public ListComponent getFocusedComponent() {
if (focusedIndex<0 || focusedIndex>=components.size()) return null;
return (ListComponent) components.elementAt(focusedIndex);
}
/**
* Gets the selected item on this list form.
*
* @return the selected item on the list form, or null if no item is selected
*/
public int getFocusedIndex() {
return focusedIndex;
}
/**
* Processes a press of a key.
* @param keyCode the pressed key
*/
public void keyPressed(int keyCode) {
int index = 0;
for (Enumeration e = components.elements(); e.hasMoreElements(); index++) {
Object obj = e.nextElement();
if (obj instanceof ListComponent) {
if (((ListComponent) obj).getShortcut()==keyCode) {
changeFocus(index);
super.keyPressed(PlatformCanvas.KEY_SOFT_RIGHT);
return;
}
}
}
if (keyCode == KEY_UP) {
if (getPreviousFocusable() == -1 && (this.getScrollDirections() & SCROLL_UP) == 0) {
changeFocus(getLastFocusable());
return;
}
}
if (keyCode == KEY_DOWN) {
if (getNextFocusable() == -1 && (this.getScrollDirections() & SCROLL_DOWN) == 0) {
changeFocus(getFirstFocusable());
return;
}
}
super.keyPressed(keyCode);
}
} // class ListScreen
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -