📄 roundtitle.java
字号:
import com.nttdocomo.ui.Button;
import com.nttdocomo.ui.Dialog;
import com.nttdocomo.ui.IApplication;
import com.nttdocomo.ui.ListBox;
import com.nttdocomo.ui.SoftKeyListener;
import com.nttdocomo.ui.TextBox;
import com.nttdocomo.ui.Label;
import com.nttdocomo.ui.Component;
import com.nttdocomo.ui.ComponentListener;
import com.nttdocomo.ui.HTMLLayout;
import com.nttdocomo.ui.Panel;
public class RoundTitle extends Panel implements ComponentListener, SoftKeyListener {
private Cricket parent = null;
private ListBox lstUser = null;
private Button btnStart = null;
private TextBox[] txtUsers = new TextBox[TConst.MAX_PLAYER_CNT];
private Label[] lblDisp = new Label[TConst.MAX_PLAYER_CNT+1];
private Label[] lblMargin = new Label[TConst.MAX_PLAYER_CNT+4];
private HTMLLayout layout = null;
public RoundTitle(Cricket _parent) {
super();
// 弶婜壔
this.parent = _parent;
this.initialize();
/* 僜僼僩僉乕侾儔儀儖偺愝掕 */
setSoftLabel(SOFT_KEY_1, "廔椆");
// Listener僀儞僗僩乕儖
setComponentListener(this);
setSoftKeyListener(this);
}
private void initialize() {
this.setTitle("MAIN.");
this.setBackground(TColor.AQUA);
layout = new HTMLLayout();
setLayoutManager(layout);
// 儕僗僩弶婜壔
lstUser = new ListBox(ListBox.CHOICE, TConst.MAX_PLAYER_CNT);
for ( int i=1 ; i<=TConst.MAX_PLAYER_CNT ; i++) {
lstUser.append(""+i);
}
lstUser.select( 1 );
// 僥僉僗僩弶婜壔
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT ; i++) {
txtUsers[i] = new TextBox("", 8, 1, TextBox.DISPLAY_ANY);
txtUsers[i].setInputMode(TextBox.KANA);
if ( i>1 ) {
txtUsers[i].setEnabled(false);
}
}
txtUsers[0].setText("");
txtUsers[1].setText("");
// 儔儀儖弶婜壔
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT+1 ; i++) {
lblDisp[i] = new Label("儐乕僓柤");
lblDisp[i].setBackground(TColor.AQUA);
}
lblDisp[0].setText("儐乕僓悢");
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT+4 ; i++) {
lblMargin[i] = new Label();
lblMargin[i].setBackground(TColor.AQUA);
}
// 儃僞儞弶婜壔
btnStart = new Button(" START! ");
int height = getHeight() / (TConst.MAX_PLAYER_CNT +4);
int width = getWidth() / 10 * 4;
int margin = height / 5;
// set size
lstUser.setSize( width , height);
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT ; i++) {
txtUsers[i].setSize( width, height);
}
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT+1 ; i++) {
lblDisp[i].setSize( width, height);
}
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT+4 ; i++) {
lblMargin[i].setSize( width, margin);
}
btnStart.setSize(getWidth()/3, height);
// 夋柺偵儃僞儞捛壛
layout.begin(HTMLLayout.CENTER);
add( lblMargin[0] );
layout.br();
add(lblDisp[0] );
add(lstUser );
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT ; i++) {
layout.br();
add( lblMargin[i+1] );
layout.br();
add(lblDisp[i+1] );
add(txtUsers[i] );
}
layout.br();
add( lblMargin[TConst.MAX_PLAYER_CNT+1] );
layout.br();
add( lblMargin[TConst.MAX_PLAYER_CNT+2] );
layout.br();
add(btnStart );
//layout.br();
//add( lblMargin[TConst.MAX_PLAYER_CNT+3] );
layout.end();
}
public void componentAction(Component src, int arg1, int arg2) {
if ( src.equals( btnStart ) ) {
// System.out.println( "start pressed." );
parent.showCanvas(true);
}
else if ( src.equals( lstUser ) && arg1 == SELECTION_CHANGED) {
// System.out.println("selected changed." + lstUser.getSelectedIndex() );
for ( int i=0 ; i<TConst.MAX_PLAYER_CNT ; i++) {
if ( i>lstUser.getSelectedIndex() ) {
txtUsers[i].setEnabled(false);
} else {
txtUsers[i].setEnabled(true);
}
}
}
}
public int getPlayerCount() {
return lstUser.getSelectedIndex()+1;
}
public String getPlayerName(int player) {
if ( player < 0 || player >= TConst.MAX_PLAYER_CNT ) {
return "";
}
return txtUsers[player].getText();
}
public void refresh() {
// 傕偟昁梫偱偁傟偽捛壛偡傞
}
public void softKeyPressed(int arg0) {
}
public void softKeyReleased(int arg0) {
if (SOFT_KEY_1 == arg0) {
Dialog dialog = new Dialog(Dialog.DIALOG_YESNO, "廔椆妋擣");
dialog.setText("傾僾儕働乕僔儑儞傪廔椆偟傑偡丅\n傛傠偟偄偱偡偐丠\n\n");
int ans = dialog.show();
if (Dialog.BUTTON_YES == ans) {
IApplication.getCurrentApp().terminate();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -