I have the following simple question. Is it possible for someone to have two Java Swing application windows from which events could be captured?
I have the following scenario. I have an app which runs on a touch enabled device running Windows 7. Said app spawns another child JFrame. Now, if I click on the parent frame, I get the window's focus and I can perform actions. Doing the same on the child frame also does the same getting the focus from the parent.
What I want to do, is to be able to handle click events on both screens - that is don't block the other frame when someone is interacting with the other one.
Is there a way to do something like that?
Related
I am using Java to create an foreground application that uses the Robot class to send mouse clicks to other applications real-time.
Here's my issue at the moment: my application needs to read from a device in real time and keep sending Robot commands. However, mouse clicks cause the focus to be shifted to other applications. Therefore, I cannot continue reading or sending commands.
I've tried jDialog's and jFrame's setAutoRequestFocus(false) and true but I couldn't keep the window's focus.
Can anyone help me with this?
I need to get the absolute location of mouse after a click on the screen. I've already searched on the web but the only solution I have found uses this method:
MouseInfo.getPointerInfo().getLocation()
which gets the position independently from the click.
Otherwise, i have to use an EventListener to check out when the mouse is clicked, but the problem is that listeners are related to a component, while i need the absolute location.
How can i solve this?
This is an OS dependent feature. As far as I understand your question, you don't have a GUI or you don't want to add a listener to your GUI components. JVM will only receive clicks for components that are related to it.
Here you have to write some native code to hook to events that you want on your own, or you should use a library like jnativehook that does the same thing for you and you don't need to write code for Linux, Mac OS X and Windows.
I'm creating a new JFrame from within an already running JFrame. Both frames are separate applications, but in this case, the second application gets a "plugin handle" of the first application instead of using its default stuff. For some operations in the second app, a callback is made to the first app to know what to do/display.
This way, the second application can be reused by many other applications. It is and will NOT be possible to manually start some java.exe command to achieve a real separate process.
Now, to emphasize that the second JFrame is another application, I want the taskbar entry to not be grouped together with the entry that was already there for the first JFrame. So basically this is a Windows 7 issue in combination with Java.
The icons on the taskbar are grouped together by default, there is enough space for them to be displayed separately but they simply don't.
How can I display the JFrame's icons separately on the taskbar? I can't find anything on JFrame that does what I want.
I am creating an desktop application that runs at background and while clicking the control button it should be visible i have made the setVisible(false) to the JFrame any idea how to do it . The application should triggered if you click the control button twice in desktop or in any application this should work.
This can't be done in your application.
If it runs in the background, it doesn't have the focus, so it can't react on that event. Any other application might have the focus and being interested in consuming the Ctrl button.
Think of multiple such programs, all in concurrence for that button. Which should get informed? Think of 3 Editors, all getting the next character typed.
Your OS or DE might have a way to define a hotkey, look whether your program is running (once?), and send a message to your application. The application might then react.
I want to partially automate some integration level tests via the use of the Robot class to send mouse/keyboard events to the the Java application I'm testing. I want the user to be able to click a button and have a number of keyboard events be automatically sent at once.
I spawn the application I want to test from inside my Robot test (using Runtime.exec) and then generate the appropriate events. Unfortunately when the user clicks a button the button has focus and receives the events instead of the events going to the child process as I would like. I would like a way to ensure that the Robot keyboard events are sent to the application I'm trying to test instead.
I've thought of fetching the child process PID and then using the FG command to bring the application I want to the foreground; but this is a Linux specific approach. I would prefer a method that works for Linux or Windows equally as well.
I don't know exactly what you are testing or how you are testing it but you should look into Sikuli - its a visual technology and there are methods that will let you either automatically click on a part of the screen you want to get focus, or use App.focus("application name"). I really recommend it. However using it will not let you use the computer to do other things while testing the program.
Hope that helps!