I would like to write a really simple and rudimentary UI in Java that would run on a Windows machine in a very similar fashion like it runs in a terminal window. Basically I need to put a colored character output into a window on the screen and in reaction on keys hit by the user I would like to modify the content of the screen. If it can react on mouse clicks, the better, but not fully necessary.

I need it to write a utility for data processing that will be used just internally. No pretty UI needed, I only need to write it fast. It could have scroll bars if my text exceeds the screen. It should allow clearing the screen and filling it with different character data and ideally also doing some smaller change like replace the text at some position or change the color of some of the displayed text.

I could do it using just normal Windows terminal window but it lacks some features that would be nice to have. Like colored output, updates of the text on the screen without clearing the whole screen, using the mouse for input. Pretty similar as once DOS programming was - for those who still remember these ancient days.

I could probably use Swing and make it very pretty or use some web app and present it in the browser but that is everything very complicated. I want to write smt like

output("Hello world");
output("Press any key");

I guess such a library can be written on top of any modern sophisticated UI engine, just would need to get a tip if something like that exists. Extremely primitive and easy to use, NOT looking nicely and could be Windows only or whatever like that.

(I tried to ask on Stackoverflow but there they were not happy with this question, not sure how, because it it in fact a Java programming topic. But also it is a search for a 3rd party library so I am trying here).

  • On Stack Overflow there is (or at least was) a close reason specifically when asking for libraries and tools. This site is the right place to ask. May 19 '20 at 17:25
  • There is Jansi and Chalk. Haven't used them, so I can't comment on the libraries quality. May 19 '20 at 17:27
  • Yes, thanks a lot for your tip! It is something similar what I wanted. I got Chalk with Jansi working. Just for the record when someone reads this later - I had to modify the jansi jar by removing the classes that are overridden in Chalk (I compiled it directly). Also there is an important Windows configuration change you need to do to get it work - see github.com/fusesource/jansi/issues/161.
    – TomFT
    May 19 '20 at 22:41
  • Feel free to post your own answer when you find one of these libraries worth recommending to someone else. You can even mark an own answer as accepted. May 20 '20 at 5:31
  • I know, just the libraries do not really fit to what I described in my question, so technically they are not the answer. But they were good enough for what I needed. Thanks for your help.
    – TomFT
    May 21 '20 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.