Is it possible to press keypad programmatically so that number for the key pressed shows on the screen? See the screenshot below for more explanation please:
Details:
Nokia N70
CLDC 1.1
MIDP 2.0
How you approach it will depend on what you want to achieve.
You can quite easily simulate pressing keys on a Canvas, by calling your Canvas's keyPressed(), keyReleased() and keyRepeated() methods directly.
This could be good for testing a canvas-based game, ensuring a given state is entered when certain keys are pressed on the canvas.
However, this won't allow you to control any form-based interaction, or native prompts. So you can't start the MIDlet, navigate through a LCDUI Form or List, accept a native security prompt, or edit a native TextBox. You'd need to use an emulator and some form of test scripting framework which simulates keypresses, such as Eggplant.
if you want to mimicking the keypressed process, just call the keypressed with the int of key as argument, for example keyPressed(-8);
Or are you trying to display the key number in the screen ?
Related
I'm fluent in java, and have messed with vb.net, but I prefer java. I wish to make a program that ++'s a variable everytime I click my mouse in a certain coordinate on my screen. Not sure how to record when a mouse click has happened outside of the program's forms.
This can't be done in pure Java but people have written JNI libraries that can capture global mouse and keyboard events. Take a look at
https://github.com/kwhat/jnativehook
Is it possible to have my android application start a method from pressing of the convenience key when the application in focus?
On my phone the convenience key is a button located on the right hand side of the phone. I would like to be able to know if the user presses any of the buttons on the phone, even the volume would work.
You are welcome to override onKeyDown() on your Activity and watch for a KeyEvent of interest. Note that not every key in the KeyEvent JavaDocs is accessible this way (e.g., power). Also note that it is possible that some specific View that is aware of these keys might consume the event first, though that is relatively unlikely for anything that matches your description of a "convenience key".
I have an application which runs in fullscreen mode but I want to make it so when the user presses Alt-Tab, Windows key + Tab or Ctrl+Alt+Delete, nothing happens.
I have tried doing requestFocus() every frame so if the user tabs out, it tabs back in but it doesn't do anything. Also JFrame.setAlwaysOnTop() doesn't make it always on top if the user tabs out. So how would I prevent the user from tabbing out?
Thanks.
It's possible to disable some key combinations - is it is possible to disable the windows keys using java
But, you cannot disable or override alt+ctrl+delete.
You shouldn't generally disable these key combinations though even if you can. If a user wants to alt+tab, let them. Otherwise you'll have some angry and fleeting users.
Wondering how to link a keyboard key to a JButton in netbeans, Downloaded KeyEventDemo program from oracle that lets you press a key and it tells you the keycode, Now im wondering how to implement that, working on a calculator project and I already have the ability to click on any button and have it either +,-,/,* or enter so now I am wondering how to link the 2 together, essentially I'm trying to figure out how to check which key is being pressed in a method, and then run a method depending on what they pressed! thanks for any info!
See How to Use Key Bindings. Basically you bind a KeyStroke to an Action. The tutorial also has a section on How to Use Actions.
I writing an application which controls another application by using the keyboard only. To more concrete, the application simulates key presses and mouse clicks when a certain key is pressed on the keyboard. For example, pressing on the 'x' key simulates a mouse click on the [X] in the rop right corner, followed by a little sleep of 2 seconds and an 'enter' to confirm the exit dialog. Pretty easy. I am developing this application in Java.
Sending a key press or a mouse click is very easy with java.awt.Robot. I am facing one little problem. Say I have configured a key which will click somewhere on the screen. The problem is that consecutive key presses aren't catched anymore, as my application lost its focus caused by the mouse click outside it's window.
My question now is: what is the best way to be sure that my main application keeps the focus? Is there a way to focus my application again after the key presses and mouse clicks are sent out? Is there a better way?
Thanks in advance.
If your application lost the focus. because you or your Robot clicked to somwhere else, the Robot must click on the application again before sending a new key. In c/c++ you could force the focus to the application (a non-trivial task), not in Java!
You might want to take a look at Component.requestFocus() to see if can do what you want.
Be aware however that window focusing has very platform dependent behaviour, so you will probably need to do quite a bit of testing to ensure that your code does what you want in all circumstances.
I managed a way to prevent applications from losing all focus in Java.
By placing a WindowFocusListener on the frame (or dialog) and calling setVisible(false) followed by setVisible(true) in windowLostFocus the component will re-appear as soon as it is dissapears (not the prettiest solution but it does work).
By then calling component.requestFocus() your robot should be able to continue where it left off