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

📄 qinputitem.java

📁 j2me 高级UI
💻 JAVA
字号:
/**
 * 作者:cat 戚永城
 * 时间:2008-3-1
 * QQ:415898635
 * E-Mail:	415898635@qq.com
 * 			qyc_12345@163.com
 * 
 * */
package org.qui.manager;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import org.qui.container.QFrame;
import org.qui.container.QSelector;
import org.qui.info.Key;


public class QInputItem extends QItem {

	public int fireCount = 0;

	public boolean textReady = false;

	public QInputItem(){
		super();
	}
	
	public QInputItem(int x, int y, int width, int height) {
		super(x, y, width, height);
		// TODO 自动生成构造函数存根
	}

	public void paint(Graphics g) {

	}

	public String text = "";

	public void setText(String text){
		this.text=text;
	}
	public void append(String text) {
		this.text = this.text + text;
	}
	private Input input=null;

	public void keyPressed(int keyCode) {
		if(keyCode==Key.FIRE&&editable){
			ui.selector.inInputItem=!ui.selector.inInputItem;
			if(ui.selector.inInputItem){
				QFrame frame=(QFrame)QFrame.display.getCurrent();
				input=new Input("请输入内容:",text,16384,TextField.ANY,frame);//16k
				QFrame.display.setCurrent(input);
			}
		}
		super.keyPressed(keyCode);
	}

	public void keyReleased(int keyCode) {
		super.keyReleased(keyCode);

	}
	class Input extends TextBox implements CommandListener{
		
		private Command accept=new Command("Accept",Command.OK,1);
		private Command cancel=new Command("Cancel",Command.CANCEL,1);
		private QFrame frame;
		public Input(String title, String text, int maxSize, int constraints, QFrame frame) {
			super(title, text, maxSize, constraints);
			this.frame=frame;
			addCommand(accept);
			addCommand(cancel);
			setCommandListener(this);
			
		}

		public void commandAction(Command cmd, Displayable display) {
			if(cmd.equals(accept)){
				setText(getString());
			}else if(cmd.equals(cancel)){
				
			}
			frame.setFullScreenMode(true);
			QFrame.display.setCurrent(frame);
			ui.selector.inInputItem=false;
		}
	}
}

⌨️ 快捷键说明

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