Hello,

I got a weird exception after removing a tab. Details of the exception
is at the end of this message. Even though I got the exception, the
application still functions normally and the tab can be removed
successfully. I don't know where the exception comes from and what I
should do to avoid it.

The following code is my extension to DecoratedTabPanel to make it
dynamically closable. Any input will be appreciated.

public class ClosableTabPanel extends DecoratedTabPanel {
        private boolean isReadyToRemove = false;

        public ClosableTabPanel() {
                addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() 
{
                        public void 
onBeforeSelection(BeforeSelectionEvent<Integer> event)
{
                                if (isReadyToRemove) {
                                        remove(event.getItem());
                                        isReadyToRemove = false;

                                }
                        }
                });
        }

        @Override
        public void add(Widget w, String tabText) {
                HorizontalPanel tab = new HorizontalPanel();
                Button button = new Button("x", new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                                Widget widget = (Widget) event.getSource();
                                ...
                                final ClosableTabPanel tab = (ClosableTabPanel) 
widget;
                                tab.isReadyToRemove = true;
                        }
                });

               .....
        }
}




java.lang.IndexOutOfBoundsException: null
    at
com.google.gwt.user.client.ui.ComplexPanel.checkIndexBoundsForAccess(ComplexPanel.java:
128)
    at
com.google.gwt.user.client.ui.DeckPanel.showWidget(DeckPanel.java:313)
    at
com.google.gwt.user.client.ui.TabPanel.onTabSelected(TabPanel.java:
382)
    at com.google.gwt.user.client.ui.ListenerWrapper
$WrappedTabListener.onSelection(ListenerWrapper.java:754)
    at
com.google.gwt.event.logical.shared.SelectionEvent.dispatch(SelectionEvent.java:
89)
    at
com.google.gwt.event.logical.shared.SelectionEvent.dispatch(SelectionEvent.java:
1)
    at com.google.gwt.event.shared.HandlerManager
$HandlerRegistry.fireEvent(HandlerManager.java:65)
    at com.google.gwt.event.shared.HandlerManager
$HandlerRegistry.access$1(HandlerManager.java:53)
    at
com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:
178)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52)
    at
com.google.gwt.event.logical.shared.SelectionEvent.fire(SelectionEvent.java:
43)
    at com.google.gwt.user.client.ui.TabBar.selectTab(TabBar.java:462)
    at
com.google.gwt.user.client.ui.TabBar.selectTabByTabWidget(TabBar.java:
601)
    at com.google.gwt.user.client.ui.TabBar.access$0(TabBar.java:596)
    at com.google.gwt.user.client.ui.TabBar
$ClickDelegatePanel.onBrowserEvent(TabBar.java:151)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1307)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1263)
    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
157)
    at
com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:
1713)
    at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
165)
    at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
120)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
507)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
264)
    at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:
91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
    at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
157)
    at
com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:
1668)
    at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:
401)
    at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:
222)
    at java.lang.Thread.run(Unknown Source)

-- 
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