score:0

Accepted answer

If you look at the source

class TabbedPane extends Component with Publisher {
  object pages extends BufferWrapper[Page] {
    def apply(n: Int) = 
      new Page(TabbedPane.this, peer.getTitleAt(n),
        UIElement.cachedWrapper[Component] 
        (peer.getComponentAt(n).asInstanceOf[javax.swing.JComponent]),
        peer.getToolTipTextAt(n))

you always get a new instance.

Looking at

class TabbedPane extends Component with Publisher {
  object pages extends BufferWrapper[Page] {

  def +=(t: Page): this.type = { 
    t.parent = TabbedPane.this
    peer.addTab(t.title, null, t.content.peer, t.tip)
    this
  }

the argument t is not recorded at all.

But you can change the title using

pane.pages(0).title = "Title 2"

so you could define a logical page (a companion in addition to the Swing page) separately. Using a reference to the pane and the tab index this class can change the title.


Related Query

More Query from same tag