Results 1 to 9 of 9
Thread: How can I clear the screen?
- 11-06-2012, 05:43 PM #1
Senior Member
- Join Date
- Jul 2012
- Posts
- 165
- Rep Power
- 1
How can I clear the screen?
I am making a command-line program using java.
I have done the majority of the background work and now am working on the user interface.
I am going to be asking things like "how old are you" and I will have the user type a line of text and press enter, with their input being saved as a variable.
The thing I want to happen after this is the screen clearing (no text) so that the next question can be displayed without the screen looking confusing.
Is there a way to do this?
-
Re: How can I clear the screen?
There is no such command available in core Java. Consider creating a GUI if you absolutely need this functionality.
- 11-06-2012, 06:12 PM #3
Senior Member
- Join Date
- Jul 2012
- Posts
- 165
- Rep Power
- 1
Re: How can I clear the screen?
I read that this probably wasn't possible in java, I just wanted to make sure.
In that case I'll have to use my backup solution of creating lots of newLines. I am not experienced enough for a GUI yet and for what I am doing I will not really benefit from it.
Thank you for your help though.
-
Re: How can I clear the screen?
You're welcome.
- 11-06-2012, 09:03 PM #5
Re: How can I clear the screen?
Furbarable said it, and is correct, however, there are packages designed to emulate this functionality (which is usually supplied by some variant of curses or ncurses in unix). The learning curve may be too steep for your level of experience, but check out the screenshots on the Charva project website: CHARVA: A Java Windowing Toolkit for Text Terminals
You can do simple things like in-place text changes and clearing the screen, as well as advanced stuff like simulating tabs, fields, etc...
If you MUST use a command line, this is the way to go, but as others have said, making a simple GUI window which does the same thing would be much easier. Packages like this are still popular for command line servers/systems though!
- 11-07-2012, 07:50 PM #6
Senior Member
- Join Date
- Jul 2012
- Posts
- 165
- Rep Power
- 1
Re: How can I clear the screen?
How difficult would it be to have everything which is currently command-line but in a JFrame?
All I would need is a single window and one line of text input (i.e. what a command-line window is).
- 11-07-2012, 09:38 PM #7
Re: How can I clear the screen?
You could just have a textfield and a text area - where input is the textfield and all output is in the text field.
- 11-08-2012, 11:40 AM #8
Senior Member
- Join Date
- Jul 2012
- Posts
- 165
- Rep Power
- 1
Re: How can I clear the screen?
So what do I need to start learning to do that? Swing?
Will it take too long to learn?
- 11-08-2012, 12:38 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: How can I clear the screen?
Define "too long".
It'll probably take about the same amount of time as to learn a curses/ncurses wrapper.
Here's the tutorial(s).
Skip the Netbeans IDE bit, as the GUI builder will not do you any favours.Please do not ask for code as refusal often offends.
Similar Threads
-
How to clear screen in JAVA ??
By ProgRookie92 in forum New To JavaReplies: 3Last Post: 07-03-2012, 09:00 PM -
clear screen in java
By chandrasekhar.melam in forum New To JavaReplies: 7Last Post: 09-25-2011, 03:32 PM -
is there any method for clear screen?
By chandrasekhar.melam in forum New To JavaReplies: 9Last Post: 09-22-2011, 08:32 PM -
Need For Clear Screen
By adithya4u4ever in forum New To JavaReplies: 8Last Post: 03-08-2009, 08:41 AM -
Clear screen in java
By lenny in forum New To JavaReplies: 1Last Post: 07-30-2007, 09:43 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks