You can create a graphical interface that looks like a console, for example, using JTextArea
to display console text and JTextField
, where the user can enter the information they want to send to the console. By adding KeyListener
to the JTextField
, you can listen to the user by pressing 'Enter' and then send the information to the console.
Instead of reading user input from the console (which sits and waits for the user to finish entering information, then performs an action), you simply listen to the 'Enter' key, and then call the method after going through your "JTextField" Text.
source share