Is there a Swing touch keyboard option?

493 views
Skip to first unread message

Eric Douglas

unread,
Jan 26, 2018, 4:59:26 PM1/26/18
to
If I open Chrome on my tablet I can click into any input field and the touch keyboard automatically appears. If I open a pure Swing jar app with a JFrame and a JTextField, I click into the field and it just gets focus. Am I missing something to make the keyboard appear?

Knute Johnson

unread,
Jan 28, 2018, 10:52:08 AM1/28/18
to
On 1/26/2018 15:59, Eric Douglas wrote:
> If I open Chrome on my tablet I can click into any input field and the touch keyboard automatically appears. If I open a pure Swing jar app with a JFrame and a JTextField, I click into the field and it just gets focus. Am I missing something to make the keyboard appear?
>

I think that is wound into to OS so far that you probably won't get it
to work consistently. There is a windows program, TabTip.exe, that is
an onscreen keyboard but getting it to show up when you want is another
matter.

I think I would just create my own onscreen keyboard if I didn't want my
users to have to figure out how to get the system onscreen keyboard to
work.

--

Knute Johnson

Eric Douglas

unread,
Jan 29, 2018, 9:27:14 AM1/29/18
to
On Sunday, January 28, 2018 at 10:52:08 AM UTC-5, Knute Johnson wrote:
> I think that is wound into to OS so far that you probably won't get it
> to work consistently. There is a windows program, TabTip.exe, that is
> an onscreen keyboard but getting it to show up when you want is another
> matter.
>
> I think I would just create my own onscreen keyboard if I didn't want my
> users to have to figure out how to get the system onscreen keyboard to
> work.
>
> --
>
> Knute Johnson

I found some hacks, from making the Windows keyboards appear to displaying a keyboard made from Java code. Oddly Windows seems to come with 2 keyboards, TabTip.exe and osk.exe. I already have a focus listener on my controls to display a blue focused border, so calling an exe shouldn't be so bad. Now I need to know when to call it. We're running the same code on desktops (currently running Win 8.1 Pro) and on tablets (Surface Pro 4 running Windows 10 Pro). Normally desktops will have a keyboard "attached" (some are wireless) and normally the tablets will not. I need to display the virtual keyboard only if no physical keyboard is present (or if the device supports touch screen events?). I tried searching for Java code to check this and mostly found Android code.

Runtime.getRuntime().exec(
"cmd /c \"C:\\Program Files\\Common Files\\microsoft " +
"shared\\ink\\tabtip.exe\"" );

I'm testing on desktop, will need to test on the tablet, but I think I like tabtip better than osk.

Eric Douglas

unread,
Jan 29, 2018, 10:23:04 AM1/29/18
to
On Sunday, January 28, 2018 at 10:52:08 AM UTC-5, Knute Johnson wrote:
> I think that is wound into to OS so far that you probably won't get it
> to work consistently. There is a windows program, TabTip.exe, that is
> an onscreen keyboard but getting it to show up when you want is another
> matter.
>
> I think I would just create my own onscreen keyboard if I didn't want my
> users to have to figure out how to get the system onscreen keyboard to
> work.
>
> --
>
> Knute Johnson

I see they did add a fix for Java 10, I just don't want to wait that long.
https://bugs.openjdk.java.net/browse/JDK-8166772

Displaying the touch keyboard on focus whenever a physical keyboard is not present sounds ideal. If I don't have an easy way to detect that, my workaround is adding a global flag to my API to accept a parameter on startup specifying that option. Now, I should want to hide the keyboard on focus lost? I don't see an easy way to do that other than running a kill process command. I'd rather terminate it gracefully.

Funny, tabtip is not in the default Windows path. I opened cmd.exe which defaulted to my c:\users path and typed tabtip and it says not a recognized command, but osk does work by default.

Knute Johnson

unread,
Jan 29, 2018, 10:43:52 AM1/29/18
to
It is surprising that this issue didn't bubble up earlier as touch
screens and on-screen-keyboards have been around for some time.

I don't know about using osk or tabtip, I think a Java solution would be
more likely to work now and in the future (but I have been wrong before :-)


--

Knute Johnson

Eric Douglas

unread,
Jan 29, 2018, 2:01:40 PM1/29/18
to
On Monday, January 29, 2018 at 10:43:52 AM UTC-5, Knute Johnson wrote:
>
> It is surprising that this issue didn't bubble up earlier as touch
> screens and on-screen-keyboards have been around for some time.
>
> I don't know about using osk or tabtip, I think a Java solution would be
> more likely to work now and in the future (but I have been wrong before :-)
>
>
> --
>
> Knute Johnson

tabtip sounds like the proper solution, looks like that's what Oracle is doing with Java 10 and what other people are calling most from other languages. I tried searching for a proper way to open that on focus gain (not crazy about anything using Runtime exec), and a proper way to close it (process kill is a last resort option) and best I could find is something about JNA.

I have seen threads about using a custom on screen keyboard written in Java but that sounds ridiculous on a tablet where other apps are using the built in Windows keyboard.

Andreas Leitgeb

unread,
Jan 29, 2018, 2:50:48 PM1/29/18
to
Eric Douglas <e.d.pro...@gmail.com> wrote:
> tabtip sounds like the proper solution, looks like that's
> what Oracle is doing with Java 10

The bug-link(*) seems to mention backports to 8u172 and 8u181, but doesn't
mention any 9er (maybe they just think that goes without saying)

*: https://bugs.openjdk.java.net/browse/JDK-8166772

visyboard free

unread,
Sep 7, 2022, 9:34:52 AMSep 7
to
On Saturday, 27 January 2018 at 07:59:26 UTC+10, e.d.pro...@gmail.com wrote:
> If I open Chrome on my tablet I can click into any input field and the touch keyboard automatically appears. If I open a pure Swing jar app with a JFrame and a JTextField, I click into the field and it just gets focus. Am I missing something to make the keyboard appear?
give this a try:
https://sites.google.com/view/visyboardfree/

visyboard free

unread,
Sep 7, 2022, 9:36:39 AMSep 7
to
On Saturday, 27 January 2018 at 07:59:26 UTC+10, e.d.pro...@gmail.com wrote:
> If I open Chrome on my tablet I can click into any input field and the touch keyboard automatically appears. If I open a pure Swing jar app with a JFrame and a JTextField, I click into the field and it just gets focus. Am I missing something to make the keyboard appear?
give this a try:
https://sites.google.com/view/visyboardfree/home

e.d.pro...@gmail.com

unread,
Sep 7, 2022, 9:50:16 AMSep 7
to
> > If I open Chrome on my tablet I can click into any input field and the touch keyboard automatically appears. If I open a pure Swing jar app with a JFrame and a JTextField, I click into the field and it just gets focus. Am I missing something to make the keyboard appear?
> give this a try:
> https://sites.google.com/view/visyboardfree/home

That is a Java based keyboard, sounds good if 1. There's no proper way to get the built in on screen keyboard to appear, 2. You're certain the built in keyboard will not appear.
Reply all
Reply to author
Forward
0 new messages