Customize The DisclosurePanel Widget

810 views
Skip to first unread message

darkAngel

unread,
Sep 10, 2007, 5:40:51 AM9/10/07
to Google Web Toolkit, Customize
Hi:

I'm trying to customize the arrows of the DisclosurePanel widget, by
implementing the DisclosurePanelImages interface, but all my attempts
fail.

Could you help me?

public class DisclosurePanelImagesImpl implements
DisclosurePanelImages {

public AbstractImagePrototype disclosurePanelClosed() {
return new AbstractImagePrototype() {
private Image image = null;

public void applyTo(Image image) {
if (image == null) {
throw new NullPointerException();
}
this.image = image;
}

public Image createImage() {
return image;
}

public String getHTML() {
return "<img src='images/down.png'>";
}
};
}

public AbstractImagePrototype disclosurePanelOpen() {
return new AbstractImagePrototype() {
private Image image = null;

public void applyTo(Image image) {
if (image == null) {
throw new NullPointerException();
}
this.image = image;
}

public Image createImage() {
return image;
}

public String getHTML() {
return "<img src='images/up.png'>";
}
};
}

}

Peter Blazejewicz

unread,
Sep 10, 2007, 4:51:49 PM9/10/07
to Google Web Toolkit
hi,
in fact that is very easy, just crete new interface extending
disclosure panel images and use proper constructor,
e.g.:

public class TestModule implements EntryPoint {
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
DisclosurePanelImages images = (DisclosurePanelImages) GWT
.create(MyCustomArrows.class);
final DisclosurePanel disclosurePanel = new DisclosurePanel(images,
"My panel", true);
rootPanel.add(disclosurePanel, 5, 5);
disclosurePanel.setSize("150px", "150px");

}

public interface MyCustomArrows extends DisclosurePanelImages {
// @Override
/**
* @gwt.resource drafts.gif
*/
public AbstractImagePrototype disclosurePanelClosed();

// @Override
/**
* @gwt.resource home.gif
*/
public AbstractImagePrototype disclosurePanelOpen();
}

}

regards,
Peter

darkAngel

unread,
Sep 11, 2007, 3:14:22 AM9/11/07
to Google Web Toolkit
Hi:

Thank you for your reply.

As I see, you are using deferred binding. But I wonder where is the
implementation of your customized interface?
Where can I code the name of the pictures? (example up_arrow.png,
down_arrow.png)

Don't tell me that the names of our resources (pictures) are
mentionned in this comment?

I hope that you have understood me.

Please help.

darkAngel

unread,
Sep 11, 2007, 3:29:38 AM9/11/07
to Google Web Toolkit
Hi Friend:

I have used your code, and it leads to a failed compilation. It is due
to this line of code:

DisclosurePanelImages dpi =
(DisclosurePanelImages)GWT.create(MyCustomArrows.class);

Did you get the same error like me?

darkAngel

unread,
Sep 11, 2007, 5:49:22 AM9/11/07
to Google Web Toolkit
Hi:

Thank you for your great help.

My DisclosurePanel works nicely. I should put the entire path of the
resource if it is not in the same directory of the interface.

public interface CustomDisclosurePanelImages extends
DisclosurePanelImages {
/**
* @gwt.resource com/gwt/client/images/up.gif
*/
public AbstractImagePrototype disclosurePanelClosed();

/**
* @gwt.resource com/gwt/client/images/down.gif
*/
public AbstractImagePrototype disclosurePanelOpen();
}

CustomDisclosurePanelImages cdpi =
(CustomDisclosurePanelImages)GWT.create(CustomDisclosurePanelImages.class);

// ...

Thank you ...

Reply all
Reply to author
Forward
0 new messages