PDA

View Full Version : Draggable Textfield with Label



Pmithrandir
9 Dec 2008, 8:09 AM
Hello

I have a FormPanel with TextField who will be draggable.

I wan't to drag my textField, but just the input form are moving.

The label stay on the same place.

Have you an idea for resolve my problem ?

Thanks

Pierre



panel = new FormPanel();
Field<String> item;
item = new TextField<String>();
item.setFieldLabel("test label");
Draggable d = new Draggable(item);
d.setContainer(this);
panel.add(item);

edfimasa
10 Dec 2008, 5:44 AM
Hi.

Have you tried to add the textfield & label to a horizontalPanel or other panel, and then make that panel draggable, maybe that way all drags.

Cheers.

Pmithrandir
10 Dec 2008, 6:35 AM
Thanks for help

I have change my code like end of topic, but my field label disapear.

Is there a solution to have field label on panel other than FormPanel ?



Field<String> item;
switch (type) {
case TEXTFIELD:
item = new TextField<String>();
item.setFieldLabel(titre);
break;
case TEXTAREA:
item = new TextArea();
item.setFieldLabel(titre);
break;
default:
item = new TextField<String>();
item.setFieldLabel("Name");
break;
}
HorizontalPanel hp = new HorizontalPanel();
hp.add(item);
Draggable d = new Draggable(hp);
d.setContainer(this);
panel.add(hp);
panel.layout();

sven
10 Dec 2008, 6:43 AM
Give your "HorizontalPanel" a formlayout as layout. That would bring back your fieldlabel.

Pmithrandir
10 Dec 2008, 6:53 AM
Hello

I have make this correction :


HorizontalPanel hp = new HorizontalPanel();
FormLayout fl = new FormLayout(LabelAlign.LEFT);
hp.setLayout(fl);
hp.add(item);
Draggable d = new Draggable(hp);
d.setContainer(this);
panel.add(hp);
panel.layout();

But, no change on the result.

What is your idea when you say : Give your "HorizontalPanel" a FormLayout as layout

Pierre

edfimasa
10 Dec 2008, 6:59 AM
Sven meant to setLayout(new FormLayout) to the horizontaPanel but it will not work.

This is my solution:

(all inside a class that extends ViewPort)



HorizontalPanel p = new HorizontalPanel();
p.setSize(50, 50);

p.setLayout(new FlowLayout());

TextField<String> tf = new TextField<String>();
LabelField lf = new LabelField("TextField Label:");

p.add(lf);
p.add(tf);

Draggable d = new Draggable(p);

add(p);


adjust the sizes sa you will

Cheers. I tested it so it will work.

sven
10 Dec 2008, 7:14 AM
err, sorry.

HorizontalPanel overrides our layout again :(

so use this code:



FormPanel panel = new FormPanel();
panel.setSize(600, 600);
LayoutContainer lc = new LayoutContainer();
FormLayout layout = new FormLayout();
lc.setLayout(layout);
TextField item = new TextField<String>();
item.setFieldLabel("test");

lc.add(item);

panel.add(lc);
Draggable d = new Draggable(lc);

Pmithrandir
10 Dec 2008, 7:22 AM
Thanks a lot for you two.

I have use the second solution, who align the field.

I will try to drag and drop field with label with portal model.


Resolved