Test class
Code:
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame implements WindowListener {
private static final long serialVersionUID = 1L;
private final TextArea TA = new TextArea
("", 25, 80, TextArea.SCROLLBARS_NONE);
private final String NEWLINE = "" + '\n';
public Test() {
TA.setEditable(false);
add(TA);
setTitle("Test Application");
setResizable(false);
addWindowListener(this);
pack();
setVisible(true);
}
public void print(String s) {
TA.append(s);
}
public void println(String s) {
TA.append(s);
TA.append(NEWLINE);
}
public void cls() {
TA.setText("");
}
public void kill() {
dispose();
}
public void windowActivated(WindowEvent arg0) {
}
public void windowClosed(WindowEvent arg0) {
}
public void windowClosing(WindowEvent arg0) {
}
public void windowDeactivated(WindowEvent arg0) {
}
public void windowDeiconified(WindowEvent arg0) {
}
public void windowIconified(WindowEvent arg0) {
}
public void windowOpened(WindowEvent arg0) {
}
}
Clearscreen
Code:
public class clearscreen {
public static void main(String[] args) {
Test t = new Test();
t.println("Hello World!");
t.print("Same line ");
t.println("Test");
try {
Thread.sleep(5000);
} catch (InterruptedException e)
}
t.cls();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
t.kill();
}
}
Try this...
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum