Thanks
45 Replies - 8853 Views - Last Post: 14 August 2009 - 08:30 PM
#16
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 08:01 PM
Thanks
#17
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 08:08 PM
Locke, on 13 Aug, 2009 - 06:58 PM, said:
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'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
#18
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 08:10 PM
no2pencil, on 13 Aug, 2009 - 09:01 PM, said:
Thanks
http://www.dreaminco...topic119974.htm
#19
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 08:48 PM
#20
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 08:55 PM
KYA, on 13 Aug, 2009 - 07:48 PM, said:
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
#21
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 09:25 PM
#22
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 11:21 PM
markhazlett9, on 13 Aug, 2009 - 09:25 AM, said:
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?
markhazlett9, on 13 Aug, 2009 - 09:25 AM, said:
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?
#23
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 11:22 PM
markhazlett9, on 13 Aug, 2009 - 08:25 PM, said:
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
#24
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 11:36 PM
#25
Re: Trying to make a clearscreen in Java
Posted 13 August 2009 - 11:46 PM
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);
}
}
#26
Re: Trying to make a clearscreen in Java
Posted 14 August 2009 - 12:59 AM
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
#27
Re: Trying to make a clearscreen in Java
Posted 14 August 2009 - 01:38 AM
bbq, on 13 Aug, 2009 - 11:59 PM, said:
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!
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...
#28
Re: Trying to make a clearscreen in Java
Posted 14 August 2009 - 01:43 AM
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.
#29
Re: Trying to make a clearscreen in Java
Posted 14 August 2009 - 01:45 AM
FreezingDigits, on 14 Aug, 2009 - 12:43 AM, said:
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?
#30
Re: Trying to make a clearscreen in Java
Posted 14 August 2009 - 01:48 AM
This post has been edited by FreezingDigits: 14 August 2009 - 01:51 AM

New Topic/Question
Reply



MultiQuote





|