@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		//System.out.println("keyReleased->char:"+e.getKeyChar()+" code:"+e.getKeyCode());
		if(e.getKeyCode()==10){//з
			try {//ȡñʽַ
				mExpression=mDocument.getText(mUnableEditLength, mDocument.getLength()-mUnableEditLength-1);//з
			} catch (BadLocationException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			//System.out.println("expression:"+mExpression+"  length:"+mExpression.length());
			//¼
			String tmp=mExpression.trim();
			if(tmp.length()>0){//Ч¼
				if(commandsHistory.size()<50){//δ
					if(commandsHistory.size()>0&&!tmp.endsWith(commandsHistory.get(commandsHistory.size()-1))){//¼һ
						commandsHistory.add(tmp);
						commandIndex=commandsHistory.size();
					}else if(commandsHistory.size()==0){
						commandsHistory.add(tmp);
						commandIndex=commandsHistory.size();
					}
				}else{	//׸¼
					if(commandsHistory.size()>0&&!tmp.endsWith(commandsHistory.get(commandsHistory.size()-1))){//¼һ
						commandsHistory.remove(0);
						commandsHistory.add(tmp);
						commandIndex=49;
					}else if(commandsHistory.size()==0){
						commandsHistory.remove(0);
						commandsHistory.add(tmp);
						commandIndex=49;
					}
				}
			}
			//System.out.println(commandsHistory.size()+":"+commandIndex+commandsHistory);
			
			//жǷΪ
			String com=null;
			if((com=ParseExpression.isCommand(mExpression))==null){//
				this.printResult(ParseExpression.parse(mExpression));
			}else{//
				if(com.equals("exit")){
					System.exit(0);
				}else if(com.endsWith("clear")){
					//״̬ʼ
					this.setText(">");
					mUnableEditLength=mDocument.getLength();
					this.setCaretPosition(mDocument.getLength());
				}
			}
			//ʹˮƽ
			this.mainWindow.mScrollPane.getHorizontalScrollBar().setValue(0);
		}
		if(e.getKeyCode()==KeyEvent.VK_UP||e.getKeyCode()==KeyEvent.VK_DOWN){
			//ѹ䵽
			this.setCaretPosition(mDocument.getLength());
			this.setCaretColor(Color.BLACK);
		}
	}