I got a solution to this problem: Just put a toolbar beside the tabbed pane
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JTabbedPane;
import java.awt.FlowLayout;
import java.awt.Insets;
import javax.swing.JToolBar;
import java.awt.ComponentOrientation;
import javax.swing.JButton;
import java.awt.Cursor;
public class PanelTab extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
PanelTab frame = new PanelTab();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public PanelTab() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[] { 424, 0 };
gbl_contentPane.rowHeights = new int[] { 51, 0 };
gbl_contentPane.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
gbl_contentPane.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
contentPane.setLayout(gbl_contentPane);
JPanel panel = new JPanel();
GridBagConstraints gbc_panel = new GridBagConstraints();
gbc_panel.fill = GridBagConstraints.BOTH;
gbc_panel.gridx = 0;
gbc_panel.gridy = 0;
contentPane.add(panel, gbc_panel);
GridBagLayout gbl_panel = new GridBagLayout();
gbl_panel.columnWidths = new int[] { 184, 0 };
gbl_panel.rowHeights = new int[] { 54, 0 };
gbl_panel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
gbl_panel.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
panel.setLayout(gbl_panel);
JToolBar toolBar = new JToolBar();
toolBar.setOpaque(false);
toolBar.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
toolBar.setFloatable(false); // The toolbar must not be float
GridBagConstraints gbc_toolBar = new GridBagConstraints();
gbc_toolBar.anchor = GridBagConstraints.NORTHEAST;
gbc_toolBar.gridx = 0;
gbc_toolBar.gridy = 0;
panel.add(toolBar, gbc_toolBar);
JButton btnHola = new JButton("You must put your exit icon here");
btnHola.setOpaque(false);
toolBar.add(btnHola);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
gbc_tabbedPane.fill = GridBagConstraints.BOTH;
gbc_tabbedPane.gridx = 0;
gbc_tabbedPane.gridy = 0;
panel.add(tabbedPane, gbc_tabbedPane);
JPanel panel_1 = new JPanel();
tabbedPane.addTab("New tab", null, panel_1, null);
}
}
I guess this might help you...