Hello! I have the same problem..but i found this can not implementd..
can body help me please!!! :)
public class StackComponent extends StackLayoutPanel implements
HasChangeHandlers {
public StackComponent(Unit unit) {
super(unit);
}
@Override
public void showWidget(Widget widget) {
super.showWidget(widget);
fireEvent(new StackChangeEvent(widget));
}
@Override
public HandlerRegistration addChangeHandler(ChangeHandler handler) {
return addDomHandler(handler, ChangeEvent.getType());
}
}
this code is this page:
http://stackoverflow.com/questions/1890432/fire-event-when-switching-stacks-of-stacklayoutpanel-in-gwt-2-0
Greetings!
On Jul 13, 4:12 pm, Ali <[email protected]> wrote:
> 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.