Solved

get mouse position in java without frames or applet

Posted on 2004-04-07
12
1,308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

626 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