📄 titlepanel.java
字号:
/*
* @(#)TitlePanel.java 1.0 04/07/01 @(#)
*
* Copyright 2004 NTT DoCoMo, Inc. All rights reserved.
*/
import com.nttdocomo.ui.Component;
import com.nttdocomo.ui.ComponentListener;
import com.nttdocomo.ui.Dialog;
import com.nttdocomo.ui.HTMLLayout;
import com.nttdocomo.ui.IApplication;
import com.nttdocomo.ui.ImageButton;
import com.nttdocomo.ui.ImageLabel;
import com.nttdocomo.ui.Label;
import com.nttdocomo.ui.Panel;
import com.nttdocomo.ui.SoftKeyListener;
/**
* TitlePanel<BR>
* The definition class of the title screen.
* <p>
* @version 1.0
* </p>
*/
public class TitlePanel extends Panel
implements ComponentListener,
SoftKeyListener {
/** Hi-Score */
private Label highScore = new Label();
/** Title */
private ImageLabel title = new ImageLabel();
/** Start button */
private ImageButton startButton = new ImageButton();
/** Parent */
private CarRace parent = null;
/** Score */
private Score score = null;
/**
* Constructor.
* @param _parent Parent object
* @param _score Score object
*/
public TitlePanel(CarRace _parent, Score _score) {
super();
this.parent = _parent;
this.score = _score;
/* Setting Layout manager */
HTMLLayout lm = new HTMLLayout();
setLayoutManager(lm);
/* Setting background color of the panel */
setBackground(Color.BLACK);
/* Setting soft key 1 label */
setSoftLabel(SOFT_KEY_1, "End");
/* Setting soft key 2 label */
setSoftLabel(SOFT_KEY_2, "Rank");
/* Hi-Score */
refresh();
/* Setting title picture */
title.setImage(MediaCollection.getImage(MediaCollection.IMG_TITLE));
title.setBackground(Color.BLACK);
/* Setting start button */
startButton.setImage(MediaCollection.getImage(MediaCollection.IMG_START));
startButton.setBackground(Color.BLACK);
/* Arrangement */
lm.begin(HTMLLayout.CENTER);
lm.br();
lm.br();
add(highScore);
lm.br();
lm.br();
lm.br();
lm.br();
add(title);
lm.br();
lm.br();
lm.br();
lm.br();
lm.br();
lm.br();
add(startButton);
lm.end();
/*
* Component Listener
*/
setComponentListener(this);
/*
* SoftKey Listener
*/
setSoftKeyListener(this);
}
/**
* Sets Hi-Score on the title screen.
*/
public void refresh() {
highScore.setText("HI SCORE " + score.getHighScore());
highScore.setForeground(Color.WHITE);
highScore.setBackground(Color.BLACK);
}
/**
* Receives events from componet.
* <br>
* @param _comp Component
* @param _type Event type
* @param _param Parameter
*/
public void componentAction(Component _comp, int _type, int _param) {
/*
* Specifying the component which generated the event.
*/
if (_comp.equals(startButton)) {
/*
* Event type
*/
if (_type == BUTTON_PRESSED) {
parent.play();
}
}
}
/**
* Called when a soft key is pushed
* @param _key The pressed key
*/
public void softKeyPressed(int _key) {
}
/**
* Called when a soft key is detached
* <br>
* @param _key The detached key
*/
public void softKeyReleased(int _key) {
if (SOFT_KEY_1 == _key) {
Dialog dialog = new Dialog(Dialog.DIALOG_YESNO, "Check");
dialog.setText("Are you sure you want to end the Application?\n\n");
int ans = dialog.show();
if (Dialog.BUTTON_YES == ans) {
MediaCollection.dispose();
IApplication.getCurrentApp().terminate();
}
} else if (SOFT_KEY_2 == _key) {
parent.showRanking();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -