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'>";
}
};
}
}
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
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.
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?
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 ...