PDA

View Full Version : Background image in ContentPanel



bostone
26 Aug 2009, 10:10 AM
I have the following code that happily compiles. The intent is to display icon of the trash can inside a div


private static final AppIcons IMAGES = GWT.create(AppIcons.class);
ContentPanel trashcan = new ContentPanel();
trashcan.setHeight(100);
trashcan.setHeaderVisible(false);
trashcan.setIcon(IMAGES.trashcan_empty());This generates HTML code that does have the image, problem is - that image lives inside a div that is disabled so it's invisible


.x-hide-display {
display:none !important;
}
So I guess my question is - what's the best way to display an image that can be used for drag-n-drop. In my case I would like to drag something onto trash can to delete?

sven
26 Aug 2009, 10:12 AM
setIcon in ContentPanel sets an icon in the header, the part you hide.


cp.add(IMAGES.trashcan_empty().createImage())

bostone
26 Aug 2009, 12:34 PM
setIcon in ContentPanel sets an icon in the header, the part you hide.
Thanks, indeed that was the case. The information I overlooked was createImage() call

bostone
26 Aug 2009, 3:19 PM
Now - I'm probably doing something wrong again, but I'm trying to center the image and it stays left-aligned:


ContentPanel west = new ContentPanel();
west.setLayout(new FillLayout());

ContentPanel trashcan = new ContentPanel();
trashcan.setSize(1, 100);
trashcan.setHeaderVisible(false);
trashcan.setLayout(new CenterLayout());
trashcan.add(IMAGES.trashcan_empty().createImage());
west.setBottomComponent(trashcan);

sven
26 Aug 2009, 11:41 PM
A width of 1px is not really enough.

bostone
27 Aug 2009, 6:40 AM
A width of 1px is not really enough.
Hm, according to spec int from 0 to 1 is treated as percent, so 1 is really a 100% isn't it? Anyway - doing trashcan.setSize(200, 100) didn't help, as well as calling trashcan.layout() after the image is added. I'm just wondering if setting bottom component behaves differently.