General Java Questions I
Robot rMouse=new Robot();
int button=1;
rMouse.mousePress(button);
rMouse.mouseRelease(button);
I am really confused. Will you please give me some advice? Thank you in advance!
Answer: You are not using a valid value for the argument to the mousePress() and
mouseRelease() methods. If you check the API documentation, you ll find the valid
values are a combination of one or more of the following constants:
InputEvent.BUTTON1_MASK
InputEvent.BUTTON2_MASK
InputEvent.BUTTON3_MASK
plus others which represent the Ctrl, Alt, and Shift keys. To press the left 
mouse button, you want to use:
rMouse.mousePress(InputEvent.BUTTON1_MASK);
  
Lee Weiner
 Q: In what situation an exception has to be caught otherwise the compiler will
complain?
e.g. IOException does NOT have to be explicitly caught, however, SQLException has
to be caught otherwise VisalAge will not compile the program.
Answer: The only unchecked exceptions in Java are RuntimeException and its
subclasses. This includes such familiar classes as NullPointerException,
ClassCastException, and IndexOutOfBoundsException.
IOException is not one of these, and *does* have to be explicitly caught or thrown
  
jeff_robertson
 Q: Is it possible to use switch with range of values?
Ex:
switch (iBegins){
   case 2 to 10:
}
Answer: 
not exactly like this but:
switch (iBegins){
   case 2:
   case 3:
   case 4:
   case 5:
   case 6:
   case 7:
   case 8:
   case 9:
   case 10:
       /* do stuff */
       break;
file:///F|/a_jsite/350_tips/general_java I.htm (28 of 33) [2001 07 08 11:24:51]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved