Reputation: 103
I was wondering if there was some sort of command I could output that would clear the netbeans output window? I just want the current output to clear, but still have the ability to output more after clearing at run time. Something similar perhaps to BlueJ's:
System.out.print('\u000C');
Upvotes: 0
Views: 8009
Reputation: 11
If you use Netbeans, use this method:
public void clear() throws AWTException {
Robot rob = new Robot();
try {
rob.keyPress(KeyEvent.VK_CONTROL); // press "CTRL"
rob.keyPress(KeyEvent.VK_L); // press "L"
rob.keyRelease(KeyEvent.VK_L); // unpress "L"
rob.keyRelease(KeyEvent.VK_CONTROL); // unpress "CTRL"
Thread.sleep(1000); // add delay in milisecond, if not there will automatically stop after clear
} catch (InterruptedException e) {
}
}
add import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
Upvotes: 0
Reputation: 285430
You asked:
I was wondering if there was some sort of command I could output that would clear the netbeans output window?
No, not with a standard console. To do this you need to create either a Swing GUI and clear your text component, use another GUI such as SWT, or use a non-standard 3rd party console.
Upvotes: 1