Trying to make a clearscreen in Java

try to help me..

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

45 Replies - 8853 Views - Last Post: 14 August 2009 - 08:30 PM Rate Topic: -----

#16 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 08:01 PM

Can you provide a link to this other topic?

Thanks :)
Was This Post Helpful? 0
  • +
  • -

#17 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 08:08 PM

View PostLocke, on 13 Aug, 2009 - 06:58 PM, said:

LOL.

pbl just confirmed, in the other thread by this OP, that the only way to "clear" the console is to print a bunch of lines until you can't see anything that was there. :)
I guess somebody should write a console API for Windows using <ESC> code
I'll have to look into that one day
We'll have to find out a old C program that allow to write bold or even flashing stuff to a DOS console
if somebody can find a link to these codes I'll write the API and post it here
Was This Post Helpful? 1
  • +
  • -

#18 Locke   User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 552
  • View blog
  • Posts: 5,624
  • Joined: 20-March 08

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 08:10 PM

View Postno2pencil, on 13 Aug, 2009 - 09:01 PM, said:

Can you provide a link to this other topic?

Thanks :)


http://www.dreaminco...topic119974.htm :D
Was This Post Helpful? 1
  • +
  • -

#19 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 08:48 PM

There's more then one. In fact, a safe bet is that there is at least one a week.
Was This Post Helpful? 0
  • +
  • -

#20 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 08:55 PM

View PostKYA, on 13 Aug, 2009 - 07:48 PM, said:

There's more then one. In fact, a safe bet is that there is at least one a week.

still does not give me a link to those DOS console f*** Escape sequences :)

Should be really easy to implemnt a DOSConsole class with:
void writeAt(String str, int row, int col);
void clearFrom(int col, int row, int col);
void setCursorAt(int row, int col);
....
these methods just have to call Syste,out.print() with the good escape sequences
Was This Post Helpful? 1
  • +
  • -

#21 markhazlett9   User is offline

  • Coding is a lifestyle
  • member icon

Reputation: 61
  • View blog
  • Posts: 1,666
  • Joined: 12-July 08

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 09:25 PM

What is this topic even about anymore :crazy: :blink: :S
Was This Post Helpful? 0
  • +
  • -

#22 ice_skate3   User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 78
  • Joined: 13-March 09

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 11:21 PM

View Postmarkhazlett9, on 13 Aug, 2009 - 09:25 AM, said:

Please don't say that our answers are wrong unless you know for sure that they are...

You absolutely cannot delete text from the console in Windows, Mac or Linux. This isn't anything wrong with the OS it's actually to do with the OS itself. You CAN'T change that. if you want to delete text please use a GUI or use the technique i described earlier.

As far as i can tell your code to "delete text" is just a simple linked list. So I don't know really what you're asking anymore...

Cheers


there was a delete code!
and his answer was actually wrong,. i'm askig for a java... and when i run it.. it won't work..

here's the example code''

you can try this in your java...

ok!

public class InsSLList {

	protected IntSLLNode head, tail;

	public InsSLList() {
		head = tail = null;
	}
	public boolean isEmpty() {
		return head == null;
	}

	public void addToHead(int el) {
		head = new IntSLLNode (el,head);
		if (tail == null)
		tail = head;
	}
	public void addToTail(int el, String str) {
		if (!isEmpty()) {
			tail.next = new IntSLLNode(el,str);
			tail = tail.next;

		}
		else head = tail = new IntSLLNode(el,str);
	}
	public int deleteFromHead() { // delete the head and return its info;
		int el = head.info;
		if (head == tail) // if only one node on the list;
			head = tail = null;
		else head = head.next;
		return el;
	}
	public int deleteFromTail() { // delete the tail and return its info;
		int el = tail.info;
		if (head == tail) // if only one node on the list;
			head = tail = null;
		else {			// if more than one node on the list,
		IntSLLNode tmp; // find the predecessor of tail;
		for (tmp = head; tmp.next != tail; tmp = tmp.next);
		tail = tmp;		// the predecessor of tail becomes tail;
		tail.next = null;
	}
	return el;

	}
	public void printAll() {
			for (IntSLLNode tmp = head; tmp != null; tmp = tmp.next)
				System.out.print(tmp.info + " " + tmp.value + " ");
	}
	public boolean isInList(int el) {
		IntSLLNode tmp;
		for (tmp = head; tmp != null && tmp.info != el; tmp = tmp.next);
		return tmp != null;
	}

	public void delete(int el) {  // delete the node with an element el;
		if (!isEmpty())
			if (head == tail && el == head.info)   // if only one
				head = tail = null;
			else if (el == head.info) // if more than one node on the
				head = head.next;	// list; and el is in the head node;
			else {
				IntSLLNode pred, tmp;// and el is in a non-head node;
				for (pred = head, tmp = head.next;
					 tmp != null && tmp.info != el;
					 pred = pred.next, tmp = tmp.next);
				if (tmp != null) {  // if el was found;
					 pred.next = tmp.next;
					 if (tmp == tail) // if el is in the last node;
						tail = pred;
				 }
			}
		}
	public static void main(String args[])
	{
		InsSLList ins = new InsSLList();
		ins.addToTail(7,"Seven");
		ins.addToTail(3,"Three");
		ins.addToTail(5,"Five");
		ins.printAll();
		System.out.println();
		ins.deleteFromTail();
		ins.printAll();
		System.out.println();
		System.out.println(ins.isEmpty());
	}
}



ins.deleteFromTail();

and why are u saying that there was no such thing like deleting?


View Postmarkhazlett9, on 13 Aug, 2009 - 09:25 AM, said:

Please don't say that our answers are wrong unless you know for sure that they are...

You absolutely cannot delete text from the console in Windows, Mac or Linux. This isn't anything wrong with the OS it's actually to do with the OS itself. You CAN'T change that. if you want to delete text please use a GUI or use the technique i described earlier.

As far as i can tell your code to "delete text" is just a simple linked list. So I don't know really what you're asking anymore...

Cheers


there was a delete code!
and his answer was actually wrong,. i'm askig for a java... and when i run it.. it won't work..

here's the example code''

you can try this in your java...

ok!

public class InsSLList {

	protected IntSLLNode head, tail;

	public InsSLList() {
		head = tail = null;
	}
	public boolean isEmpty() {
		return head == null;
	}

	public void addToHead(int el) {
		head = new IntSLLNode (el,head);
		if (tail == null)
		tail = head;
	}
	public void addToTail(int el, String str) {
		if (!isEmpty()) {
			tail.next = new IntSLLNode(el,str);
			tail = tail.next;

		}
		else head = tail = new IntSLLNode(el,str);
	}
	public int deleteFromHead() { // delete the head and return its info;
		int el = head.info;
		if (head == tail) // if only one node on the list;
			head = tail = null;
		else head = head.next;
		return el;
	}
	public int deleteFromTail() { // delete the tail and return its info;
		int el = tail.info;
		if (head == tail) // if only one node on the list;
			head = tail = null;
		else {			// if more than one node on the list,
		IntSLLNode tmp; // find the predecessor of tail;
		for (tmp = head; tmp.next != tail; tmp = tmp.next);
		tail = tmp;		// the predecessor of tail becomes tail;
		tail.next = null;
	}
	return el;

	}
	public void printAll() {
			for (IntSLLNode tmp = head; tmp != null; tmp = tmp.next)
				System.out.print(tmp.info + " " + tmp.value + " ");
	}
	public boolean isInList(int el) {
		IntSLLNode tmp;
		for (tmp = head; tmp != null && tmp.info != el; tmp = tmp.next);
		return tmp != null;
	}

	public void delete(int el) {  // delete the node with an element el;
		if (!isEmpty())
			if (head == tail && el == head.info)   // if only one
				head = tail = null;
			else if (el == head.info) // if more than one node on the
				head = head.next;	// list; and el is in the head node;
			else {
				IntSLLNode pred, tmp;// and el is in a non-head node;
				for (pred = head, tmp = head.next;
					 tmp != null && tmp.info != el;
					 pred = pred.next, tmp = tmp.next);
				if (tmp != null) {  // if el was found;
					 pred.next = tmp.next;
					 if (tmp == tail) // if el is in the last node;
						tail = pred;
				 }
			}
		}
	public static void main(String args[])
	{
		InsSLList ins = new InsSLList();
		ins.addToTail(7,"Seven");
		ins.addToTail(3,"Three");
		ins.addToTail(5,"Five");
		ins.printAll();
		System.out.println();
		ins.deleteFromTail();
		ins.printAll();
		System.out.println();
		System.out.println(ins.isEmpty());
	}
}



ins.deleteFromTail();

and why are u saying that there was no such thing like deleting?
Was This Post Helpful? 0
  • +
  • -

#23 depricated   User is offline

  • Nero


Reputation: 2532
  • View blog
  • Posts: 6,273
  • Joined: 13-September 08

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 11:22 PM

View Postmarkhazlett9, on 13 Aug, 2009 - 08:25 PM, said:

What is this topic even about anymore :crazy: :blink: :S

I think I inadvertently piqued pbl's interest in in writing a new API for the console . . . ?


err, skate, dude

Read over that example code you're giving us. That's just a simple Linked List. It's not going to do anything with the console.

This post has been edited by depricated: 13 August 2009 - 11:24 PM

Was This Post Helpful? 0
  • +
  • -

#24 ice_skate3   User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 78
  • Joined: 13-March 09

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 11:36 PM

View PostNeumann, on 13 Aug, 2009 - 06:57 PM, said:

View Postice_skate3, on 12 Aug, 2009 - 09:06 AM, said:

ican you fix it? huhuh!

What the fuck?


YOu shut up old man!

you're are not helping!

haven't your parents taught you a good manner?

instead of answering the question, you answered it in a wrong way!

UNPROFESSIONAL!!

disgusting!
Was This Post Helpful? 0
  • +
  • -

#25 ice_skate3   User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 78
  • Joined: 13-March 09

Re: Trying to make a clearscreen in Java

Posted 13 August 2009 - 11:46 PM

1 add
2 display all
3 delete
4 exit

enter your choice:

...if ill gonna press 1...

[the following will appear]


type your id number :
type your name :
type your last name :
type your age :

after i type, it will be back on

1 add
2 display all
3 delete
4 exit

and when i click 2

it will display what i'd type on choice 1
and then if i type
3 it will delete all on what i've typed in 1 (add)




import java.util.*;
public class S
{
	static Scanner kb=new Scanner(System.in);
	public static void main(String [] args)
{
int id=0;
int age=0;
int menu=0;
String fname="",lname="";
char bol=0;

System.out.println();
System.out.println("MENU\n");
System.out.println("[1]  ADD");
System.out.println("[2]  DELETE");
System.out.println("[3]  DISPLAY ALL");
System.out.println("[4]  EXIT");
System.out.println();


do{

System.out.println();
System.out.print("Enter your CHOICE here: ");
menu=kb.nextInt();


switch(menu)
{
case 1:
System.out.println();
System.out.println("\nYou've Choose 1 ADD");
System.out.println();
System.out.print("Please Enter ID: ");
id=kb.nextInt();
System.out.print("First Name	 : ");
fname=kb.next();
System.out.print("Last Name	  : ");
lname=kb.next();
System.out.print("Age			: ");
age=kb.nextInt();


break;

case 2:
System.out.println("\nYou have Choosen Delete");

break;

case 3:
System.out.println("\nYou Have Choosen Display All");


System.out.println();

System.out.println("ID		  : "+id);
System.out.println("First Name  : "+fname);
System.out.println("Last Name   : "+lname);
System.out.println("Age		 : "+age);
break;

case 4:
System.out.println("\nExit");
System.exit(0);
break;

default:
System.out.print("\nInvalid input\n\n");
break;
}

}while(menu !=0);

}
}


Was This Post Helpful? 1
  • +
  • -

#26 DaneAU   User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,620
  • Joined: 15-May 08

Re: Trying to make a clearscreen in Java

Posted 14 August 2009 - 12:59 AM

So you want to delete all the things the user has input in a previous loop ? Perhaps when delete is selected, just set everything to null or zero.

eg. in here
case 2:
System.out.println("\nYou have Choosen Delete");
id = 0;
age = 0;
// etc...
break;


This post has been edited by bbq: 14 August 2009 - 01:01 AM

Was This Post Helpful? 0
  • +
  • -

#27 ice_skate3   User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 78
  • Joined: 13-March 09

Re: Trying to make a clearscreen in Java

Posted 14 August 2009 - 01:38 AM

View Postbbq, on 13 Aug, 2009 - 11:59 PM, said:

So you want to delete all the things the user has input in a previous loop ? Perhaps when delete is selected, just set everything to null or zero.

eg. in here
case 2:
System.out.println("\nYou have Choosen Delete");
id = 0;
age = 0;
// etc...
break;



wahHHhH! i million thnx to you!

you solve it!

thank you so much

GOD blESS you!

:D

but wait...
when i choose display all

ID : 0
First Name :
Last Name :
Age : 0

there was a 0 zero displaying in the ID and Age..

is there a way to hide the zero? ahe^.^

but thnx anyway...
Was This Post Helpful? 0
  • +
  • -

#28 FreezingDigits   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 24
  • Joined: 17-July 09

Re: Trying to make a clearscreen in Java

Posted 14 August 2009 - 01:43 AM

Why exactly are you wanting to delete all the data from the variables?

If you'd like to enter different information into the variables you can just press 1 again and all the new data
you type will automatically overwrite the past data.
Was This Post Helpful? 0
  • +
  • -

#29 ice_skate3   User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 78
  • Joined: 13-March 09

Re: Trying to make a clearscreen in Java

Posted 14 August 2009 - 01:45 AM

View PostFreezingDigits, on 14 Aug, 2009 - 12:43 AM, said:

Why exactly are you wanting to delete all the data from the variables?

If you'd like to enter different information into the variables you can just press 1 again and all the new data
you type will automatically overwrite the past data.


well,

it's because it's part of our project... u must enter a code for delete all.. and if you'll press 1.. then, whats the use of 3 by the way? :D
Was This Post Helpful? 0
  • +
  • -

#30 FreezingDigits   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 24
  • Joined: 17-July 09

Re: Trying to make a clearscreen in Java

Posted 14 August 2009 - 01:48 AM

Alright, just asking as I don't see the real reason of it unless you're deleting the stored information under a specific name like you would do in a phone book.

This post has been edited by FreezingDigits: 14 August 2009 - 01:51 AM

Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4