I want to clear my output screen in Java using NetBeans IDE 6.9.1
botthing is not something defined in the JDK, and if it is a class that you defined, your compiler is not finding it.
Try using:
try {
Robot pressbot = new Robot();
pressbot.keyPress(17); // Holds CTRL key.
pressbot.keyPress(76); // Holds L key.
pressbot.keyRelease(17); // Releases CTRL key.
pressbot.keyRelease(76); // Releases L key.
} catch (AWTException ex) {
Logger.getLogger(LoginPage.class.getName()).log(Level.SEVERE, null, ex);
}
Brandon Durst
Updated on July 09, 2022Comments
-
Brandon Durst almost 2 years
My entire code can be found at the link below, I'm linking it for the sake of a shorter post
I want to clear the Output screen, I'm to make the program simulate a user pressing ctrl+L, which in NetBeans IDE 6.9.1 (which I'm using) clears my output window. However, I'm getting errors with my code.
public static void clearme() { try { botthing pressbot = new botthing(); pressbot.keyPress(17); // Holds CTRL key. pressbot.keyPress(76); // Holds L key. pressbot.keyRelease(17); // Releases CTRL key. pressbot.keyRelease(76); // Releases L key. } catch (AWTException ex) { Logger.getLogger(LoginPage.class.getName()).log(Level.SEVERE, null, ex); } }
My errors were...
Cannot find symbol symbol: class botthing
cannot find symbol symbol: class AWTException
cannot find symbol symbol: variable Logger
cannot find symbol symbol: class LoginPage
cannot find symbol symbol: variable Level
HOWEVER! After adding these import statements
import java.awt.AWTException; import java.util.*; import java.io.*; import java.util.logging.Level; import java.util.logging.Logger;
my errors are...
cannot find symbol symbol: class botthing location: class program2
exception java.awt.AWTException is never thrown in body of corresponding try statement
cannot find symbol symbol: class LoginPage location: class program2
I'm not sure what those mean, but I think the java.awt error could be related to my main(), which is public static void main(String[] args) throws IOException
All I want to do is clear my output screen. I've also tried
for(int x=0;x<999;x++) { System.out.print("\b\b\b\b\b"); }
and
Runtime.getRuntime().exec("cls");
but both to no avail.
If the code I've been trying can't be easily fixed, or if someone knows an easier way, I'd love to know. To clarify, all I want to do is clear my Output window after multiple System.out.println's and such.
-
Brandon Durst about 11 yearsI pasted in that code, but my errors are: | exception java.awt.AWTException is never thrown in body of corresponding try statement | cannot find symbol symbol: class Robots location: class program2 | cannot find symbol symbol: class LoginPage location: class program2 |
-
BackSlash about 11 years@BrandonDurst My mistake, just a typo, it is Robot and not Robots, however this error means you didn't import your classes, to import Robot class put
import java.awt.Robot;
after the package declaration if you have one, for other classes i don't know what you have to import, as they are not java pre-defined classes, you have to look how the package that contains your classes is named and import them -
Brandon Durst about 11 yearsI'm still getting the error "cannot find symbol symbol: class LoginPage location: class program2" also, it clears my 'table heading lines'
-
Brandon Durst about 11 yearsNevermind, apparently it was a timing issue. I inserted "for(int crap=0;crap<99999;crap++){}" after the clearme() statement and it fixed it.