Adding a JButton to a JTabbedPane tab is well documented. However, is there a way to make sure that the JButton completely fills the tab area so that when the user clicks on JButton it is not possible to click on the tab area.
Could you please elaborate more on your query as in what exactly you are looking for.
public class TabbedPaneExample extends JFrame
private static final long serialVersionUID = 1L;
JTabbedPane tabbedPane = new JTabbedPane();
setTitle( "Tabbed Pane Application" );
setSize( 300, 200 );
JPanel topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );
JPanel panel = new JPanel();
JButton button = new JButton("Click!");
topPanel.add( tabbedPane, BorderLayout.CENTER );
public static void main(String args)
TabbedPaneExample obj = new TabbedPaneExample();
Thanks for the short code sample.
In the tab, where you have the text "Hello", if that was a JButton which filled the whole tab(i.e. where the word "Hello" is) then that is exactly what I am trying to achieve. It should not be possible to activate the ChangeListener for this tab. Other tabs should be unaffected and should operate as normal.