Make Keyboard Appear Automatically - java

Is there a way to make the keyboard appear automatically on its own, without the user having to press the textfield first.
I noticed that if I use textfield.pointerRelased(0, 0) the keyboard shows up but its not functional.

You can give your textfield a focus and fire keyboard open by doing this:
Display.getInstance().editString(textfield, textfield.getMaxSize(), TextArea.ANY, textfield.getText());
There is also some newer way to do this which are slightly simpler and should work with the next plugin update. For the common use case of editing a text field/area once a form is shown use:
myForm.setEditOnShow(textfield);
Just to launch editing use:
textField.startEditing();
Or better yet:
textField.startEditingAsync();
Which is equivalent to wrapping startEditing with a callSerially. That's generally a good practice to workaround some odd platform specific bugs.

Related

Movilizer: Can I show numeric keyboard automatically and bypass the ok button?

I am working with Movilizer v15 in eclipse neon.
Currently, I am making a quiz, where people need to answer a number of questions with numeric values. But every question now consists of clicking on the answer (attributeType="2") to open the numeric keyboard, followed by answering, closing it again and pressing ok. This get's very tedious after a while.
So my question: Is there a way I can bypass opening the keyboard or having to click twice to move on to the next screen?
You can focus an Answer in the onEnterAssignment of a Question. If that Answer is of attributeType="2" this should open the numeric keyboard of the platform right away. If that keyboard allows "tabbing" forward, you can move from input field to input field. I think on Android the standard keyboard can do that.
focus(answ-desc answer, str clientKey)
Limitations might be
input fields across complex UIs
triggering OK event after the last input field is left

JavaFX 8 : Where is TextField key/mouse handling done?

I'm creating a TextField-subclass to handle time input. I want to disable selecting the text with the mouse or Maj-Left, Maj-Right, Ctrl+A, etc...
Where can I find the place in the JavaFX source code which handles all this stuff ? I did not find anything in the TextField/TextInput control. I need to see how it's done to figure out the best way to disable it.
Thank you,
Thibaut

JAVA .. validating input when textfields lose focus

I'm (a beginner) creating a sign up form in netbeans. What I really want to happen is, a JOptionPane will appear when the textfield loses focus if a users input is wrong . I've been searching for the answer on the internet for the whole day but the answers I find don't satisfy me.
You need to implement a FocusListener, add it to your textField and in your focusLost implementation of the FocusListener you need to do whatever you want it to do when focus is lost.
http://docs.oracle.com/javase/tutorial/uiswing/events/focuslistener.html
I'm not experienced with NetBeans but I'm assuming you use the graphical tool to create your form. I think you will need to start coding to implement the listener.
You should be using an InputVerifier for this type of validation.

Hear text (screenreader) when mouse hovers over a JMenu object in Java / Windows

When using a screenreader, like NVDA, I want to be able to hear the text of the menu when I hover my mouse over it. I am able to hear the text when I push the buttons in the menubar, but not when I hover over them (the screenreader does reads the menu's of other programs when only hovering over the buttons).
I have set the AccessibleContext like below:
JMenu.getAccessibleContext().setAccessibleName("text");
JMenu.getAccessibleContext().setAccessibleDescription("more text");
I can set listeners to the objects that detects when a mouse hovers over them, but I do not know if/how I can cast a text to the screenreader to read. I tried ToolTipText, but that text is not read by the screenreader either. RequestFocus on the JMenu works, but setting the focus to an object just by hovering over it with the mouse provides other problems.
Does anyone knows how I can let a screenreader reads the JMenu-text when hovering with the mouse over the menubar?
I am using Java6 EE and the Java AccesBridge (version 2.02) on a Windows machine (XP and w7).
Swing is the weaker of the GUI technologies relating to accessibility in Java, compared to SWT at any rate. There's a few things you can try.
First is to make sure any accessibility fields are set (which you've started on). I can't remember if Java has an AccessibleRole field, but you can try setting that to menu and menuitem for your menu items.
Another thing you can try is the AccessibleMenu JMenu.AccessibleJMenu component. This one's the product of further reading, so I can't verify it from experience. But it and its surrounding classes may suit your needs.
If those don't work, you could try the option of talking to people's screen readers directly. Quentin C has a good library to do this, Universal Speech. I'm new to this library myself, but it does have a Java implementation in there that should show you how to use it in a Java program. Normally I wouldn't recommend this approach unless making the UI accessible really isn't working.
The last option would be to use the SWT components instead of the Swing ones, even if just for your menu bar. I wasn't sure how keen you'd be on this one, but it is an option and should resolve it.
I hope one of these suggestions helps you solve your problem.

how to handle focus lost and focus gain event using "shift + tab" and "tab"?

I want the ability to gain the focus on the next focusable component on clicking tab and to get the focus back on the previous component on shift + tab. So need a help on how to achieve the same.
thanks
Unless I misunderstand your question, what you describe is the default behavior of java Swing on Windows and probably on Linux too. Mac OSX handles tab focus a bit differently (not all elements are reachable by default).
If you want to customize the keyboard focus order and things like that, the default API to do that is via java.awt.KeyboardFocusManager.

Categories