I have a question regarding the gridbag layout in a tabbed pane. The following piece of code (http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html) works fine, however it is used with a normal Pane. If i try a tabbed pane like this: jTabbedPane3 = new JTabbedPane(); GridBagLayout jTabbedPane3Layout = new GridBagLayout(); JButton button; jTabbedPane3.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; button = new JButton("Button 1"); c.weightx = 0.5; c.gridx = 0; c.gridy = 0; jTabbedPane3.add(button, c); jTabbedPane3.setLayout(jTabbedPane3Layout); jTabbedPane1.addTab( "jTabbedPane3", null, jTabbedPane3, null); I get all kinds of strange message errors the moment i click on jTabbedPane3 tab: Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(Unknown Source) at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(Unknown Source) at javax.swing.plaf.metal.MetalTabbedPaneUI.paint(Unknown Source) at javax.swing.plaf.metal.MetalTabbedPaneUI.update(Unknown Source) at javax.swing.JComponent.paintComponent(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintToOffscreen(Unknown Source) at javax.swing.BufferStrategyPaintManager.paint(Unknown Source) at javax.swing.RepaintManager.paint(Unknown Source) at javax.swing.JComponent._paintImmediately(Unknown Source) at javax.swing.JComponent.paintImmediately(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)