I’ve built a program in Java that’s pure text or CLI. Now I would like to build a GUI on top of it.
Back when I was in school, I only learned how to build a program around a GUI and not a GUI around the program.
How would I go about doing so?
Thank you.
EDIT: Apparently I was completely misunderstood. Aside from inputting arguments, I have things like progress information and stuff which I display using strings in the CLI model. I already know the basics of building GUIs and graphical input interface.
Before you write your GUI, refactor your CLI until it’s not doing any actual work. That is, you have a clear barrier of separation between input gathering and data manipulation.
For example, imagine a CLI that manages some inventory. This would be bad:
It’s good in that it does what it should. It’s bad in that the CLI is doing the work, not some other interface. A better approach would be
Now all your CLI does is gather input, and pass that input into some manager.
Once EVERY command in your CLI is in the format of “gather input and pass it into some manager class”, you are ready to make your GUI. When you make your GUI, you call the exact same methods you would in your CLI, you just get your data from the GUI fields instead of from the CLI!