Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I create a JTabbedPane with editable tab labels

 
Faiz Chachiya
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I create a JTabbedPane with editable tab labels
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Faiz Memon:
How do I create a JTabbedPane with editable tab labels


Since 1.6 there is a method JTabbedPane#setTabComponentAt(int index,Component component)
You can use this to provide your custom component which will enable the user to edit the tab label.

If you cannot use 1.6, you might consider using a trigger (JPopupMenu on right clicking the tab perhaps), ask the user for the new text (Using the JOptionPane#showInputDialog() perhaps) and set the new title by using the JTabbedPane#setTitleAt(int index,String title)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic