Thanks so much.
That worked perfectly

Regards

On Monday, May 6, 2019 at 11:08:42 PM UTC-4, Shai Almog wrote:

> I thought this would make an interesting blog post so I wrote a full 
> working sample. My initial mock had a mistake in listener registration:
>
> Form hi = new Form("Tabs", new BorderLayout());
>
> Tabs t = new Tabs();
>
> t.addTab("T1", new Label("Tab 1"));
> t.addTab("T2", new Label("Tab 2"));
> t.addTab("T3", new Label("Tab 3"));
> t.addTab("T4", new Label("Tab 4"));
>
> Container tabsC = t.getTabsContainer();
> tabsC.setDropTarget(true);
> for(Component c : tabsC) {
>     c.setDraggable(true);
>     c.addDropListener(e -> {
>         e.consume();
>         Component dragged = c;
>         int x = e.getX();
>         int y = e.getY();
>         int i = tabsC.getComponentIndex(dragged);
>         if(i > -1) {
>             Component dest = tabsC.getComponentAt(x, y);
>             if(dest != dragged) {
>                 Component source = t.getTabComponentAt(i);
>                 int destIndex = tabsC.getComponentIndex(dest);
>                 if(destIndex > -1 && destIndex != i) {
>                     String title = t.getTabTitle(i);
>                     t.removeTabAt(i);
>                     if(destIndex > i) {
>                         t.insertTab(title, null, source, destIndex - 1);
>                     } else {
>                         t.insertTab(title, null, source, destIndex);
>                     }
>                 }
>             }
>             tabsC.animateLayout(400);
>         } 
>     });
> }
>
> hi.add(CENTER, t);
> hi.show();
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/0ab5344b-7641-46a4-ba1b-b3e91c999cc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to