Results 1 to 9 of 9
- 08-14-2010, 06:49 AM #1
is it possible to do this to methods?
String gg = "KeyEvent.VK_1";
robot.keyRelease(KeyEvent.VK_1);
could i some how put the gg variable in replace so its like robot.keyRelease(g);
Now i know the above code doesnt work, but is there a way like this to do it?Teaching myself java so that i can eventually join the industry! Started in June 2010
- 08-14-2010, 09:05 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 08-14-2010, 10:01 AM #3
oh i see, good news. Im loving Javas flexibility to be honest.
Teaching myself java so that i can eventually join the industry! Started in June 2010
- 08-14-2010, 01:39 PM #4
Since keyRelease takes an int, not a String, you could code it this way:
int gg = KeyEvent.VK_1;
robot.keyRelease(gg);
- 08-14-2010, 01:42 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 08-14-2010, 01:59 PM #6
Sorry, I don't see how reflection converts a String to an int.
Sounds more like a javac function, but that is into byte code which could be returned as an int via a method call.
- 08-14-2010, 02:09 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 08-14-2010, 02:32 PM #8
Thanks for that.
That's my new thing learned for today.Last edited by Norm; 08-14-2010 at 02:37 PM.
- 08-14-2010, 03:01 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Something new on a Saturday? Oh dear, better forget all about it then because reflection (or even worse: the Introspector object) doesn't play the game by the rules. You can do anything you like with class objects or classes itself with that stuff. It makes you part of the virtual machine and breaks every protection or access right you'd normally have. Besides that, it's more expensive to use than ordinary object use; it's a poweful mechanism and extremely dangerous in the hands of newbies ...
kind regards,
Jos
Similar Threads
-
Trouble with static methods and boolean equals() methods with classes
By dreamingofgreen in forum New To JavaReplies: 8Last Post: 04-16-2012, 11:00 PM -
Methods Please help
By bdario1 in forum New To JavaReplies: 33Last Post: 03-25-2010, 03:26 AM -
methods
By lilac87 in forum New To JavaReplies: 7Last Post: 07-22-2009, 06:37 PM -
How to get methods to see variables in other methods
By ejs7597 in forum New To JavaReplies: 4Last Post: 04-03-2009, 06:36 AM -
methods
By Zensai in forum New To JavaReplies: 10Last Post: 12-03-2007, 05:31 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks