⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acceptmessage.java

📁 J2ME书中重点教学程序
💻 JAVA
字号:
package src;

import java.io.IOException;
import java.io.InputStream;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

public class AcceptMessage extends Thread implements CommandListener
{
	private InputStream is;
	
	private List list;
	
	private Client client;
	
	private Command cancel;
	
	public AcceptMessage(Client x) 
	{
		client = x;
		
		is = client.getIn();
		
		list = new List("显示信息",List.IMPLICIT);
		
		cancel = new Command("返回",Command.CANCEL,1);
		
		list.addCommand(cancel);
		
		list.setCommandListener(this);
		
		// TODO 自动生成构造函数存根
	}
	
	public void run()
	{
		while(true)
		{
			String temp = "";
			while(true)
			{
				try 
				{
					int ch = is.read();
					
					if(ch==-1||ch=='\n')
					{
						break;
					}
					
					temp = temp+(char)ch;
				} 
				catch (IOException e) 
				{
					
					// TODO 自动生成 catch 块
					e.printStackTrace();
				}
				
			}
			
			list.append(temp, null);
			
			client.showList(list);
		}
		
	}
	
	public List getList()
	{
		return list;
	}

	public void commandAction(Command command, Displayable arg1) 
	{
		String lab = command.getLabel();
		if(lab.equals("返回"))
		{
			client.show();
			
		}
		
		// TODO 自动生成方法存根
		
	}
	
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -