Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Moving a StringBuilder object around the x,y cartesian coordinates of a shell - is it possible?

 
Ted North
Ranch Hand
Posts: 201
1
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to make a shell game but immediately ran into an obstacle with being able to move a StringBuilder around the x, y space of a terminal shell. Is this possible? I know it is possible with a GUI using things like JLabels that can hold pictures and stuff...

Thank-you for reading.

Respectfully,

Tedster
 
Maxim Karvonen
Ranch Hand
Posts: 121
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Ted.

May you clarify your question? StringBuilder is not a visual component. It resides in the computer memory and there are no notion of "x" or "y". Terminal displays some characters, but these characters are not a StringBuilder thing. They are just character on a terminal (they may originate from some StringBuilder however).

Do you want to output text in some specific places of a console? In this case google for "java curses" or "java ncurses". There are several libraries available. I can't suggest any specific library because I never used them.
 
Ted North
Ranch Hand
Posts: 201
1
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maxim Karvonen wrote:Hi, Ted.

May you clarify your question? StringBuilder is not a visual component. It resides in the computer memory and there are no notion of "x" or "y". Terminal displays some characters, but these characters are not a StringBuilder thing. They are just character on a terminal (they may originate from some StringBuilder however).

Do you want to output text in some specific places of a console? In this case google for "java curses" or "java ncurses". There are several libraries available. I can't suggest any specific library because I never used them.


Maxim,

Thank-you for the reply! I did not think about java curses or know there was such a thing until your reply. I have seen this type of display technology elsewhere, python, but did not know java had a version of it or something. It is a bummer I would have to learn a whole new API though and can not use the the basic JDK.

The curses framework maybe my best option. I was wanting to do something like Space Invaders in a terminal shell or command prompt.

Regards,

Ted
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
remember, the terminal is really a legacy of printers. Back in the day, they didn't have CRT screens, and everything was printed out on a piece of paper. so graphics don't really make sense. You print it, the paper scrolls up, you print the next line.

It sounds like it is possible, but it's probably not the best way to do it. If you want graphics and things to move around, you'd do better to use tools that are designed for such things, such as the GUI/Swing components.
 
Ted North
Ranch Hand
Posts: 201
1
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:remember, the terminal is really a legacy of printers. Back in the day, they didn't have CRT screens, and everything was printed out on a piece of paper. so graphics don't really make sense. You print it, the paper scrolls up, you print the next line.

It sounds like it is possible, but it's probably not the best way to do it. If you want graphics and things to move around, you'd do better to use tools that are designed for such things, such as the GUI/Swing components.


Thank-you for the interesting reply Fred. With this in mind I think I am going to use a 3D game engine like jMonkey, or the built in Swing classes, or give JavaFX a spin.

Respectfully,

Ted
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic