I'm trying to create a simple console and I found this: Create a "Command" Console
I decided to try it out and it seems perfect for my need. Only problem is, I can't seem to get the user input from the user because the BufferedReader is blocked. I'm not familiar with BufferedReader nor JConsole so I can't find out what needs to be fixed.
Here's my version of the code:
import java.io.*;
import bsh.util.*;
import java.awt.*;
public class CLI extends JConsole
{
public CLI()
{
Font font = new Font("Consolas", Font.BOLD, 12);
setFont(font);
new InputThread().start();
}
private class InputThread extends Thread
{
BufferedReader input = new BufferedReader(getIn());
String newline = System.getProperty("line.separator");
String line = "";
String prompt = "$ ";
public void run()
{
try
{
do
{
print(prompt, Color.RED);
line = input.readLine();
print("You typed: " + line + newline, Color.BLUE);
} while (!line.equalsIgnoreCase("quit"));
input.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}