I want to open an on-screen keyboard (osk or tabtip) when a Text field gets focus. This works but, in my current case, the popup keyboard always hides the Text field.
Is there any way to either influence the position of the window when it is started or to move it once it is opened?
I start the keyboard using ProcessBuilder.
cmd /C pathToExe
For my particular case it would be enough to fix it to the top-left of the screen.
(Using Java 1.6 and eclipse3 RCP, target Windows 8)
This post might help you: Can I move another program's window to the front of focus?
They are adjusting the window's Z-position (whether it is on top of other windows or not) but the Windows API they are accessing allows you to change X and Y position, too.
Related
I'm trying to create an application, which will be always on top and always receiving keyboard input. There was no problem with setting the Jframe on top (setAlwaysOnTop(true)), but I have some problems with the keyboard. Whenever a windows popouts (for instance Windows update or AV update), although the JFrame is still on top it looses keyboard focus. Even minimizing & maximizing (with alt + tab) doesn't help and I need to shut down and rerun the application. Is there any elegant and simple way to set pernament keyboard focus on the JFrame? I'm starting the application through the command line.
Thanks in advance for Your help :)
String cmd = "start calc.exe";
Process process = Runtime.getRuntime().exec(codeString);
I can call calculator out, but I wish to specify a accurate position like (200,300).
how can I rewrite my cmd String?
I know that java.awt.window can set a window or frame to the specific position.
Is there any method I can use to fill frame or window with my process?
There is no clean pure java solution because JDK does not provide API that can control non-java windows. So, if you want to can use JNI/JNA.
But I can suggest you a patch that will typically work.
Windows OS allows moving windows using keyboard. Try the following manually:
Win+R
type calc and press enter
press alt+space
press M
press enter
now use arrows to move the window. Press ESC to exit this mode.
All these actions can be implemented using java.awt.Robot.
So, you can run calculator and then immediately move its window where you want.
Well, this is not clear solution, but very simple one.
Expected Problems:
Alt+space is mapped to other, custom application
Other window that started together with calc overlaps it.
User will see that window is created somewhere and then quickly moved.
So, everything depends on how important all this for you. This solution is good as an exercise or demo but bad for real commercial application.
I want to change the color of the title bar and also the Java icon on the upper left of the frame, so I can make my program (GUI) look better. Is there a simple way to change it?
I'm not sure how useful this observation is, but under the X Window System (e.g. on Linux), the titlebar and the icons in it aren't usually under the control of the application, they're “decorations” under the control of the window manager (WM). I'm not sure exactly how this might impact a Java program — they might be able to use undecorated windows and add their own equivalent — but it's equally possible that what you want to do simply isn't possible (without an inordinate amount of effort) on any platform.
I am trying to develop an application which responds to multiple digital pens (IRIS Pens) so that if any of the pen writes on paper; I relay the output to a single screen. Thus making a multi-input whiteboard for myself.
In Ubuntu these pens are recognized as mouse and thus can be handled in a similar manner as mouse events are handled.
So now what I plan to do is to handle these events in C/C++ using XLib and pass these events to a Java Swing application using JNI callback. I am able to do this but when the X11 window looses focus no events are transferred to the Swing frame. I also tried to use the root window in X11 but it does not seem to work.
Any help would be really appreciated. Thanking you in advance.
How about maximizing the C/X11 window in front of the Java one, and making it transparent? You should be able to see the Java window while still focusing on the C/X11 one.
Since you are using Ubuntu, you can achieve this using the "Opacity, brightness and saturation" plugin for Compiz. It is in the compiz-plugins-main package, and you can activate it with Compiz Settings Manager (from the compizconfig-settings-manager package). When you activate the plugin, alt+wheel is bound by default to change the transparency of the focused window.
Try reading the mouse directly. I don't remember the exact location, but you should find it in something like '/dev/input/mouseX', where X is the number of your device, ranging from 0 to n-1 devices..
When you read the packet, your application should block until the mouse moves and then your read function will return a raw mouse packet which describes the delta (which is probably more useful then the screen coordinates, in your case) and the mouse button statuses.
The raw packet can be decoded as described here: http://www.computer-engineering.org/ps2mouse/
Create a modal dialog and set it to XmDIALOG_SYSTEM_MODAL (the actual name of the property depends on your toolkit: Motif, Gtk, Qt, ...). Dialogs like this block the whole display and can never loose focus.
The drawback is of course that you can't do anything else while this dialog is on the screen.
This entry in the X11 FAQ might help.
Using Java is there anyway to display a custom form/image that behaves similar to TrayIcon.displayMessage() function in that it displays just above the system tray for a while then disappears?
I am also looking for a way to display multiple notifications at the same time by having them display above each other.
If not, how do I find the pixel location for the lower left corner just above the system tray?
I don't think there's a shortcut for drawing frames that act just like the standard TrayIcons (with the x button in the corner) that support stacking akin to the Mac Growl notifications.
you will probably have to implement it yourself.
I've found that stacking messages like that is a complete waste of time as the user will not pay attention to them - the better location for these is in the status area of the application in a simple popup menu.
You can use java.awt.GraphicsEnvironment. getLocalGraphicsEnvironment() to get information about the desktop, which contains 'getMaximumWindowBounds()' which takes care of things like the taskbar position.
You can use a subclass of a javax.swing.JWindow to create a window without a border which can be positioned on the desktop relative to the bottom right corner. This will not always work as the default tray icon, as the location of the icon generator can be somewhere else other than that.
You can add a button that acts like the 'x' button of a standard desktop window - but it's going to be platform dependent.
I use square windows that stack up from the top right corner if I'm using LTR, and it seems to work well.
Go check out Java GNOME. It has Java bindings for GTK, including a status icon for the tray, and notification events.