tag:blogger.com,1999:blog-3296335177913866771.post8839738558893146446..comments2022-10-11T19:32:50.703-04:00Comments on C O D E R Y: JTabbedPane with close button that sets the tab title correctlyAnonymoushttp://www.blogger.com/profile/10641305923669467133noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-3296335177913866771.post-28725659990562608292011-04-01T17:38:11.313-04:002011-04-01T17:38:11.313-04:00I furthered this approach by subclassing JTabbedPa...I furthered this approach by subclassing JTabbedPane like so:<br /><br />public class UJTabbedPane extends JTabbedPane {<br /><br /> @Override<br /> public void setTitleAt(int index, String title) {<br /> ButtonTabComponent.setTitleAt(index, title);<br /> super.setTitleAt(index, title);<br /> }<br /> <br />}<br /><br />And then some changes to the ButtonTabComponent:<br /><br />public class ButtonTabComponent extends JPanel {<br /> private final JTabbedPane pane;<br /> private final JLabel label;<br /> private final JButton button = new TabButton();<br /> <br /> public static void setTitleAt(int index, String title){<br /> ButtonTabComponent btc = (ButtonTabComponent) UTabManager.getTheOnlyTabbedPane().getTabComponentAt(index);<br /> btc.setTitle(title);<br /> }<br /> <br /> public void setTitle(String title){<br /> label.setText(title);<br /> }<br /><br />}Jayhttps://www.blogger.com/profile/01847534117815075166noreply@blogger.com