How can i place button on top right hand corner of the tabbed pane

Hi all,
i want to place button on top right hand corner of the tabbed pane, just run the code below, i have add button(it going to insert tab into tabbedpane), i want to place that tab into top right hand corner of the tabbedpane (not inside the tab itself). if i set tab policy setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT), it will give two button at right hand corner along with those buttons i want to and one more add button.
please suggest so that i can move forward.
Thanks in advance
import java.awt.Dimension;
import java.util.HashMap;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
* @author  Dayananda.BV
public class TabpaneDemo extends javax.swing.JFrame {
    /** Creates new form TabpaneDemo */
    HashMap<Integer, tabpanel> panelMap = new HashMap<Integer, tabpanel>();
    public TabpaneDemo() {
        initComponents();
        createFloorPlan();
        getContentPane().setPreferredSize(new Dimension(400,400));
        jTabbedPane1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
    private void initComponents() {
        jTabbedPane1 = new javax.swing.JTabbedPane();
        add_tab_button = new javax.swing.JButton();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        add_tab_button.setText("+");
        add_tab_button.setMargin(new java.awt.Insets(0, 0, 0, 0));
        add_tab_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add_tab_buttonActionPerformed(evt);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(308, Short.MAX_VALUE)
                .addComponent(add_tab_button, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(67, 67, 67))
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(add_tab_button)
                .addGap(8, 8, 8)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE))
        pack();
    }// </editor-fold>                       
    private void createFloorPlan(){
        tabpanel floorplan_Panel = new tabpanel(panelMap.size()+1);
        panelMap.put(floorplan_Panel.getTabIndex(), floorplan_Panel);
        jTabbedPane1.add(floorplan_Panel, floorplan_Panel.getTabName());
        jTabbedPane1.setSelectedIndex(jTabbedPane1.getTabCount()-1);
    private void add_tab_buttonActionPerformed(java.awt.event.ActionEvent evt) {                                              
        createFloorPlan();
     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TabpaneDemo().setVisible(true);
    // Variables declaration - do not modify                    
    private javax.swing.JButton add_tab_button;
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration                  
    class tabpanel extends JPanel{
        private int tabIndex = 0;
        private String tabName ;
        public tabpanel(int tabIndex) {
            this.tabIndex = tabIndex;
            if(tabIndex >= 10) {
                tabName = "Floor Map"+tabIndex;
            } else{
                tabName = "Floor Map"+tabIndex+"  ";
        public int getTabIndex(){
            return tabIndex;
        public String getTabName(){
            return tabName;
}Thanks
Dayananda B V

This part of tabbed pane is not customizable as it lies in the ComponentUI(TabbedpaneUI) portion of the tabbedpane.
But I can point out the place u can change to bring the desired feature into effect.
U can find an Inner class called ScrollableTabSupport
Look for the methods createButtons where u can create extra buttons and add to the tabbed pane.
The Inner class also implements actionListener where u can implement the action for the button u added.
By this method U have to use your own extended TabbedPaneUI which u cant escape from.
Hope this will help u.

Similar Messages

Maybe you are looking for

  • Please check for this account skype he is scammer

     now he use skype call to me my mobile phone i'm  IT Recruiter  it's have more impact my occupation please delete and block this account i must delete my account . i must use skype for business but now i can not .  now second time  he send mail and u

  • RPT_MOPZ_COPY_STACK_XML shows SC version differs for JAVA and DUAL-Stack xml files

    Hi All, I am using the report/program RPT_MOPZ_COPY_STACK_XML to copy the stack xml file I used from a previous upgraded system. Systems are identical. However, report shows below.. "Software Component Version KRNL64UC7.20 [01200615320200013056] diff

  • I can't hear sounds from my ipad speaker

    I just bought Ipad mini last 2 weeks....since I have bought ...I can not hear sounds from speaker. It always shows "headphone" mode....Why? Technician tried to restore but not work....What is your suggestion? Thank you.

  • Contextual menu items

    Hi, I have iMac with most recent version of Mac OS X (Lion).  I am looking to see if there is a 3rd party program to modify the contextual menu(when you right click) to provide additonal functionality. Does anyone have a utility to do this? Thanks an

  • Unable to do a Full backup due to missing archived Files

    I had setup everything to do a full backup and when the job started, it failed. It seems not able to find the archived file. I had deleted the archived File earlier due to low storage space. Can anybody advised me ? Thanks in advance. ------From Job