Hi, I'm making a small chat program. I'm having problem with JTabbedPane, I want to remove all tabs in the JTabbedPane when the chat window closed(setvisible=false).
Then if the user click another user name it'll launch again the chat window(setvisible=true).
I'm having problem with the code so I use the setvisible method instead of making new chat window JFrame.
The problem is when I can't remove all the tabs.
this.removeAll()
I got this error
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1 at java.util.Vector.elementAt(Vector.java:430) at javax.swing.JTabbedPane.getTitleAt(JTabbedPane.java:1091) at epistle.MessageBox$2.stateChanged(MessageBox.java:79) at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:400) at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:253) at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:116) at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:50) at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:599) at javax.swing.JTabbedPane.removeTabAt(JTabbedPane.java:958) at javax.swing.JTabbedPane.remove(JTabbedPane.java:1030) at epistle.TabChat.clearTab(Tampilan.java:878) at epistle.MessageBox.closeChat(MessageBox.java:150) at epistle.MessageBox$1.windowClosing(MessageBox.java:52) at java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:332) at java.awt.Window.processWindowEvent(Window.java:1862) at javax.swing.JFrame.processWindowEvent(JFrame.java:279) at java.awt.Window.processEvent(Window.java:1820) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Window.dispatchEventImpl(Window.java:2475) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Is the JTabbedPane doesn't allow empty tab state? When I make the JTabbedPane first time, it doesn't have tab right?
Hope someone can help me,
thanks