0

I want to implement a command line interface within the Java GUI window. Is there a good way of doing this or an existing project/example I could use?

My application visualises a graph in the GUI and I would like to enter verbal commands for editing it, instead of developing a point-and-click interface for every possible command. It would be similar to a normal command line but I would have a custom parser that analyses the entered command strings.

  • You can write your command and press enter, upon which the string is sent to a listener for parsing and execution.
  • Show a scrollable history of previous commands.
  • After parsing I might want to print something onto the screen (which would go to the history area).
  • Perhaps a command-line-style prefix (">").
  • Ability to edit the current command (backspace) before submitting it (enter). Not being able to delete the prefix or previous commands in the history.
  • Up and down keys would allow navigating and repeating previous commands.
6
  • 4
    Do you have a specific question? This is a broad specification for a task. Commented Jun 1, 2012 at 15:37
  • Sounds like just a lot of complicated work involving JTextAreas and JTextFields. :( Commented Jun 1, 2012 at 15:40
  • @Michael I dont know, it doesnt sound like it should be too bad assuming you dont need to edit or modify the previous commands. All you would need to to is iterate through the collection of previous commands and maybe the results of that command and paint it in a a scrollable pane. Commented Jun 1, 2012 at 15:47
  • @JohnKane Yes, you would have to implement a history mechanism that remembers previous commands so you can press the arrow keys to scroll through them. You'd also have to create a parser that parses the commands, which would vary in complexity depending on your needs. Commented Jun 1, 2012 at 15:49
  • @DavidB, I didn't think I would be the first person who needs to implement something like this. So I was hoping someone would know of an existing UI library or perhaps some open-source code that I could use as a starting point. Commented Jun 1, 2012 at 18:01

1 Answer 1

2

You have the Groovy Console. See the paragraph Embedding the Console for your app swing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.