Hi,
I am using a StackPanel (called "leftStackPanel" in code) in my
application and in order to respond to Click events on this stack
panel, I have coded the following and it works fine. But classes
SourcesChangeEvents, ChangeListenerCollection, and ChangeListener are
deprecated. I tried to use alternative new classes like
HasChangeHandlers instead, but I wasn't able to code this with new
classes. Can anyone help me with this?

StackPanel  leftStackPanel = new LeftStackPanel();
StackPanelListener stackListener = new StackPanelListener();
leftStackPanel.addChangeListener(stackListener);

//inner class
class LeftStackPanel extends StackPanel implements
SourcesChangeEvents{
                ChangeListenerCollection clc;
                int current;
                public LeftStackPanel(){
                        clc = new ChangeListenerCollection();
                }

                public void showStack( int index ) {
                        int visibleStack = index;
                        int oldVisibleStack = visibleStack;
                          super.showStack(index);
                          if (oldVisibleStack != visibleStack && clc != null) {
                            clc.fireChange(this);
                          }
            super.showStack( index );
            current = index;
            clc.fireChange( this );
        }

                public int getCurrent() {
             return current;
        }

                @Override
                public void addChangeListener(ChangeListener cl) {
                        // TODO Auto-generated method stub
                        clc.add( cl );

                }

                @Override
                public void removeChangeListener(ChangeListener cl) {
                        // TODO Auto-generated method stub
                        clc.remove( cl );
                }

                /*public void onBrowserEvent(Event event){
                        super.onBrowserEvent(event);
                        //if(event.)
                        if (event.getTypeInt()== event.ONCLICK){
                                int selectedIndex = this.getSelectedIndex();

                        }
                }*/
        }

        //inner class
        class StackPanelListener implements ChangeListener{

                @Override
                public void onChange(Widget sender) {
                        int current = ((LeftStackPanel)sender).getCurrent();
                        System.out.println("index: " + current);

                }

        }


-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to