How to add close button to a JTabbedPane Tab?

前端 未结 7 1965
温柔的废话
温柔的废话 2020-11-27 05:09

I\'m working in with a JTabbedPane, I need to add a close button in the tabs to close the current one.

I have been searching and as I understand I must extend from J

7条回答
  •  遥遥无期
    2020-11-27 05:50

    jbCloseButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    int index = jtbMainTabbedPane.indexOfTabComponent(jbCloseButton);
                    jtbMainTabbedPane.remove(index);
                }
    });
    

提交回复
热议问题