0

My LWUIT application has 3 Forms:

1) FormA 2) FormB 3) FormC

The current form being displayed on the screen is FormB.

Case 1:

If the user swipes his finger LEFT on his touch screen phone, I want LWUIT to capture that event and display FormC

Case2:

If the user swipes his finger RIGHT on his touch screen phone, I want LWUIT to capture that event and display FormA

How do I do this? I think it has to do something with drag event but not sure how to implement it.

Thanks.

Nikhil
  • 1,279
  • 2
  • 23
  • 43

3 Answers3

1
just need to override pointerDragged method in form and get/cal its X,Y positions and display another form. 


new Form()
{

protected void pointerDragged(int x, int y) {
if(x,y....)
{
form3.show();

}else
{
from1.show();
}
super.pointerDragged(x,y);

}

};

here x,y can be calculated based on screen resolutions and components u have added to it.
Vijay YD
  • 514
  • 1
  • 4
  • 15
  • i implemented the pointerPressed() and the pointerReleased() method , calculated the difference between the co ordinates and then took a decision to show a particular form... – Nikhil Apr 19 '12 at 18:55
  • Hey can you please tell me how to frame the if condition here? Its not working for me. There is just one x,y here ..how do i determine the points where the drag has started and the points where the drag has ended? I wish to calculate the difference between these two points and then take a decision as to show the form on the left or form on the right – Nikhil Apr 22 '12 at 10:32
1

Use the Tabs component with 3 Containers, it supports Swipe. You can set the Tabs themselves to be hidden.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
0

instead of taking 3 forms use 3 containers under 1 form and setScrollableX(true) and add all components in appropriate containers.

Vijay YD
  • 514
  • 1
  • 4
  • 15
  • ok then have you tried with PointerPressed / Pointerdragged method.? Override those methods and get X, Y pos (any) after firing event just call other form.show() – Vijay YD Apr 19 '12 at 06:43
  • ok...do i need to add any particular eventlistener on my form? All i need is a pointer dragged event and the direction in which it is dragged. Then i can use FORMNAME.show(). can you tell me how to do that? – Nikhil Apr 19 '12 at 06:53