@Override
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		//System.out.println("keyPressed->char:"+e.getKeyChar()+" code:"+e.getKeyCode());
		if(e.getKeyCode()==10){
			this.setCaretPosition(mDocument.getLength());
		}
		if(this.getCaretPosition()<mUnableEditLength||e.getKeyCode()==8&&mDocument.getLength()<=mUnableEditLength||(mDocument.getLength()-(this.getSelectionEnd()-this.getSelectionStart())<mUnableEditLength)){
			//˸ɾ󣬾͵'>'ַǰݣ򲻿ɾڲɱ༭
			this.setEditable(false);
		}else{
			this.setEditable(true);
		}
		if(this.getCaretPosition()<mUnableEditLength&&Character.isLetter(e.getKeyChar())){
			//ǰڲɱ༭ַĻѹ궨λ
			this.setCaretPosition(mDocument.getLength());
			this.setEditable(true);
		}
		
		//ʾʷ¼
		if(e.getKeyCode()==KeyEvent.VK_UP){//ʾһ¼
			if(commandsHistory.size()>0){
				this.setCaretColor(this.getBackground());//úͱɫһֹʾλ
				if(commandIndex==0){
					commandIndex=commandsHistory.size()-1;
				}else{
					commandIndex--;
				}
				try {
					//System.out.println(mUnableEditLength+"  "+mDocument.getLength());
					mDocument.remove(mUnableEditLength, mDocument.getLength()-this.mUnableEditLength);
					mDocument.insertString(mUnableEditLength, commandsHistory.get(commandIndex), null);
					this.setCaretPosition(mDocument.getLength());
				} catch (BadLocationException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		}else if(e.getKeyCode()==KeyEvent.VK_DOWN){//ʾһ¼
			if(commandIndex>=commandsHistory.size()-1){
				//commandIndex=0;	//ٰ£ѭ
			}else{
				commandIndex++;
				if(commandsHistory.size()>0){
					try {
						mDocument.remove(mUnableEditLength, mDocument.getLength()-this.mUnableEditLength);
						mDocument.insertString(mUnableEditLength, commandsHistory.get(commandIndex), null);
						this.setCaretPosition(mDocument.getLength());
					} catch (BadLocationException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				}
			}
		}
	}