📄 msg.java
字号:
package com.dfun.blackjack;
import javax.microedition.lcdui.*;
import java.util.Vector;
import javax.microedition.io.Connection;
/**************************************************
* @author Beetle
* 类功能介绍:
**************************************************/
public class Msg
implements CommandListener {
private Main main;
private Display display;
private Connection conn;
private TextField myMsg;
private Form msgForm;
private Command send;
private Command back;
private Displayable tempDisplay;
/*******************************************************
* 功能介绍:构造函数
* 输入参数:无
*******************************************************/
public Msg(Main main, Display display, Connection conn) {
this.main = main;
this.display = display;
this.conn = conn;
send = new Command("发送", Command.OK, 1);
back = new Command("返回", Command.BACK, 1);
msgForm = new Form("聊天室");
myMsg = new TextField(null, "", 20, TextField.ANY);
msgForm.addCommand(send);
msgForm.addCommand(back);
msgForm.append(myMsg);
msgForm.setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if (c == send) {
String strTmp = myMsg.getString();
if (strTmp.length() == 0) {
return;
}
conn.sendOneData("13" + main.strUserName + "说: " + strTmp);
myMsg.setString("");
}
else if (c == back) {
display.setCurrent(tempDisplay);
}
}
public void showForm() {
tempDisplay = display.getCurrent();
display.setCurrent(msgForm);
}
public void addMsg(String strTmp) {
msgForm.append(strTmp + "\n");
if (msgForm.size() > 6) {
msgForm.delete(1);
}
if (display.getCurrent() == msgForm) {
display.setCurrent(msgForm);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -