addListener on SplitPanel


I have SplitPanel component, which extends AbstractLayout. This particular component contains two components (eg. containers) which are split by a divider element. What I’m trying to implement here is doubleclick event on that divider element (or any other event, for that matter). Problem is that i cant pin any listener to SplitPanel. It has only one suitable addListener() overloaded method which excepts Listener class.

addListener(Listener listener);

I tried implementing ActionListener and then casting it into Listener to no avail.

So long story short : How to pin ActionListener (or ClickListener) to SplitPanel component.

Any thoughts?


If I am guessing correctly, you are trying to add “double-click collapses/expands sidebar” type of functionality? This could be most easily done on client-side by extending the ISplitPanelHorizontal and adding clicklistener there. Those clicks could then be immediately interpreted as resizes. You could even add animations fairly easily.

i tried following your advice and this is what i came up with:

my splitpanelvertical was at first extended from SplitPanel:

public class SplitPanelVertical extends SplitPanel{

if i extend ISplitPanelVertical (which is a class, and not interface, as name would suggest) and add clicklistener or actionlistener to it, i have to change my entire code where i try to extend it to my SplitPanelVertical.

public class MySplitPanel extends ISplitPanel implements ActionListener, ClickListener{

    public void actionPerformed(ActionEvent e) {
        System.out.println("we're here");

    public void buttonClick(ClickEvent event) {
        System.out.println("we're here2");

the problem is, IMHO, that SplitPanel (from what i originally extended) is extended from abstractlayout (which is in turn extended from AbstractComponentContainer). on the other hand ISplitPanelHorizontal is extended from ISplitPanel (another class) which is extended from ComplexPanel.

ISplitPanel and SplitPanel seem to be 2 different components.

Any thoughts about were to go from here?

ISplitPanel and SplitPanel seem to be 2 different components.
[/quote]You’re completely right - almost.

These two classes do actually represent the same component - one on the server-side and one on the client-side. So in order to change the behavior of the component you need to extend both of them. (the server-side component) is the one you use to build your application layout. (the client-side component) is a GWT widget that renders the component in the browser, and sends back user events to the server via Ajax.

All “ISomething”-classes are client-side counterparts to the server-side components, and not interfaces like the name might suggest.

Hopefully this clarifies things a bit.

now thats better:)

so i would need to extend ISplitPanel and by doing so, create a new GWT custom component?

i think i read something about creating custom components in ITmill manual.

Yep, that’s about right. As Joonas suggested, that way you could implement the desired functionality in the client side and do extra stuff like animations etc.

You’ll want to start here: