Solved

get mouse position in java without frames or applet

Posted on 2004-04-07
12
1,305 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 35
Need Help! Getting a syntax error and don't understand why 3 41
DTD and JAVA versions 1 33
netbeans can not run self signed app 8 14
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…

730 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