Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can we create IPhone scrolling in JTable using Swing?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can we create IPhone scrolling in touch screen using Swing?

I have a JTable in which I want to implement this function without using the scroll arrows of Scroll bar.

The things that happens in IPhone are

- Keep finger on screen --> lists scrolls up and down, slow and fast according to finger movement (1:1).

- Move finger over screen for a short distance and detach finger from screen --> List scrolls a little (slow) and then slows down and finally stops.

- Move finger over screen for a long distance and detach finger from screen --> List scrolls a lot (fast) and then slows down and finally stops.

Thanks in advance
Ajith.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of device is this code supposed to run on? Does it have a touch screen?
 
Aji Sree
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Of course. It should work in a touch screen.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of API is supported by the device? Is it something that's attached to a desktop machine, or a mobile device?
 
Aji Sree
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not a mobile device. It is a touch screen on a desktop machine.

What I am not getting is How can I relate the distance with the speed of scrolling. When I scroll long it should scroll fast and when takes the finger from screen scrolling should become slow and finally stop.
If I am scrolling short the list should scroll slow and when takes finger it should scroll slow and finally stop.

Thank you
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I have no idea what your API is like but presumably you have something like the MouseListener API.

So when you have a mousePressed event you track the point the mouse was pressed. When you get a mouseDragged event you start a Timer to do scrolling at a specified interval. As the dragged distance increases you increase the amount of each scroll. When you get a mouseReleased, you stop the Timer. So the basic trick is in calculating the scroll distance and/or frequency based on the dragged distance.
 
Aji Sree
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

Thank you very much for the help. I tried it in that way and the scrolling while dragging and on the mouse released event works now.
Also it scrolls fast and slow according to the distance of the scrolling.

But

- Move finger over screen for a long distance and detach finger from screen --> List scrolls a lot (fast) and then slows down and finally stops.

I am not getting the effect that is described in blue color.

Can anybody help in this issue?

Thanks
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, of course, when you release your finger, you need to have a thread running that sends a few more events. You might do it with the same sort of timer -- a new one that you start when the finger comes off.
 
Poop goes in a willow feeder. Wipe with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic