Results 1 to 7 of 7
  1. #1
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default Java on a touchscreen

    I've been asked to develop an application for a tablet, i.e. using a touchscreen. The application itself isn't a problem, but since I have no experience at all with touchscreens (and no real way to get the experience, since I lack a touchscreen device myself), I did the next best thing: Google it. However, I found two different answers: One claimed I need to make use of the Canvas class to capture what the user does on their touchscreen, and one suggested it should be identical to using a mouse.

    Thus, my question: Does anyone have experience themselves using touchscreens? If so, how does it work? Should I start reading into different interfaces, or will the normal ones (i.e. ActionListener, MouseListener, etc) work?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,182
    Rep Power
    20

    Default Re: Java on a touchscreen

    Depends on the tablet I presume.
    I mean, if it's Android then you won't be using Swing anyway, and it has the whole UI framework based around touchscreens.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default Re: Java on a touchscreen

    Right, should've added that in the OP... It's a Windows tablet.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,182
    Rep Power
    20

    Default Re: Java on a touchscreen

    I thought that might be the case, just wanted to be sure...:)
    Single touch used to be treated as a mouse, where touching the screen is a mouse-down at that location, and then track the movement of the finger (which may result in a click event or not).
    How you would handle multi-touch, though, I have no idea.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default Re: Java on a touchscreen

    I'm not too concerned with multi-touch (it'll be a rather simple application), so for now I'll just work under the assumption that it'll be identical to an application used with a mouse. Means I can develop it on my own computer instead of having to rely on a touchscreen device for running the application. Thanks for your help!

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,733
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java on a touchscreen

    For single touch screens you can't (easily) simulate 'right mouse clicks'. If you properly distinguish between 'finger down', 'finger up' and 'finger moved' events you can synthesize the events 'mouse pressed', 'mouse released', 'mouse entered' and 'mouse released' events. Components themselves should (optinally) synthesize them to a 'mouse clicked' event.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default Re: Java on a touchscreen

    Hmm. Good point on the rightclick... I hadn't actually thought about that one. Fortunately it shouldn't be hard to make this specific application without it though. Thanks!

Similar Threads

  1. Replies: 0
    Last Post: 09-28-2011, 12:32 PM
  2. Interactive TouchScreen - Java Programmers wanted
    By indigovision in forum Jobs Offered
    Replies: 0
    Last Post: 02-26-2009, 05:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •