Currently I am on a Java project, which is in console driven. I want to realize a feature that when the user press up arrow in the command line of my program, the command line will show the last command that the user has run.
I found something about the keyboard event as below,
public void keyPressed(KeyEvent evt);
public void keyReleased(KeyEvent evt);
public void keyTyped(KeyEvent evt);
However, I just don't know how to bring the command string to the command line. E.g., when the user presses "up", the command should bring back the the last command as a pre-input on the command line.