public void doHistory(KeyEvent e){
  if (e.getSource() == m_Input) {
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
      if (m_HistoryPos > 0) {
        m_HistoryPos--;
        String command=m_CommandHistory.elementAt(m_HistoryPos);
        m_Input.setText(command);
      }
    break;
case KeyEvent.VK_DOWN:
  if (m_HistoryPos < m_CommandHistory.size()) {
    m_HistoryPos++;
    String command="";
    if (m_HistoryPos < m_CommandHistory.size()) {
      command=m_CommandHistory.elementAt(m_HistoryPos);
    }
    m_Input.setText(command);
  }
break;
default :
break;
}
}
}

public void doHistory ( KeyEvent e ) { if ( e . getSource ( ) == m_Input ) { switch ( e . getKeyCode ( ) ) { case KeyEvent . VK_UP : if ( m_HistoryPos > 0 ) { m_HistoryPos -- ; String command = m_CommandHistory . elementAt ( m_HistoryPos ) ; m_Input . setText ( command ) ; } break ; case KeyEvent . VK_DOWN : if ( m_HistoryPos < m_CommandHistory . size ( ) ) { m_HistoryPos ++ ; String command = "" ; if ( m_HistoryPos < m_CommandHistory . size ( ) ) { command = m_CommandHistory . elementAt ( m_HistoryPos ) ; } m_Input . setText ( command ) ; } break ; default : break ; } } }
changes the currently displayed command line when certain keys are pressed . the up arrow moves back through history entries and the down arrow moves forward through history entries .
