Search code examples
lwuitlwuit-formlwuit-container

How to implement dragging in LWUIT?


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.


Solution

  • 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.