Solved

get mouse position in java without frames or applet

Posted on 2004-04-07
12
1,296 Views
Last Modified: 2012-08-13
hi,
just a quick question. if for example i move a mouse to a certain position using ajav.awt.Robot.
can i get the mouse position? without using frames or applets? so just the mouse coordinates of the current screen. is it possible? or must i use a frame or applet for it?
thanks
0
Comment
Question by:Traltixx
  • 4
  • 3
  • 2
  • +1
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10781065
i don't think you can (without native code).
0
 
LVL 2

Author Comment

by:Traltixx
ID: 10781087
cant? what do you mean by native code?
are there other languages where i can emulate mouse movement (keystrokes) and get their values/position? if there are where can i find information on it?
thanks
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10781141
If you're controlling the position of the mouse pointer, why would you need to read it? To validate that the mouse pointer actuallyu moved?

For all types of UI events in a modern OS are basically divided up into two categories; System events and application events.

System events become application events when the system has determined which application the events belong to.

java.awt.Robot, I believe, can only be used inside a Java GUI. I guess that's the whole idea with it.
0
 
LVL 92

Expert Comment

by:objects
ID: 10781148
> what do you mean by native code?

I mean you'll need to write code specific to the OS you are running on
0
 
LVL 2

Author Comment

by:Traltixx
ID: 10781184
moving and reading the mouse pointer are done in seperate classes. use in different times, but i need both.
anyway, the java.awt.Robot can be used outside the java GUI even into external applications. but i need to get the mouse position in those external applications.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 92

Expert Comment

by:objects
ID: 10781206
Pretty sure u are going to need to write native code for whatever OS you want to support.
0
 
LVL 2

Author Comment

by:Traltixx
ID: 10781211
ok..i still dont get what you mean by native code? some sort of assembly like code which can interact with the OS? arent there other languages i can use to acomplish this?
0
 
LVL 92

Accepted Solution

by:
objects earned 40 total points
ID: 10781238
for example for Windows you woould need to write a dll.
0
 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 40 total points
ID: 10782102
0
 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 40 total points
ID: 10788835
Traltixx, native code is anything that is not interpreted, e.g. C/C++ etc. It runs unmodified on the processor, the binary executable files contain processor instructions for a specific processor (processor family). For instance, native code compiled for Mac OS X/PowerPC will not run on Windows/Pentium. Instruction sets differ between processor families and are incompatible.

Java is interpreted and requires a Java Runtime for the platform on which the code is to run. Java binary code (.class files) contain processor instructions for the Java processor, which until a few years ago was a virtual processor (it didn't exist in real life). You can now buy and equip a computer with a Java processor. There is even a Java OS.

JNI bridges the gap between Java and native code. When running the javah compiler a C file is created. It is this C file you add your own platform specific code by calling into various APIs available for that platform. In your case you need to find which APIs to interface with in order to accomplish your task.

Good Luck!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now