Skip to main content

How to add actions to a TabbedPane?

2 replies [Last post]
garywang
Offline
Joined: 2007-12-05
Points: 0

I noticed that TabbedPane has an attribute onSelectionChange. How can I use it to add some actions? Or should I use other ways to add actions to it?

Please show me some code samples.
Thanks in advance!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

onSelectionChange is an attribute that has functional type:
function(javafx.ui.SingleSelection,javafx.ui.SingleSelection):*

So you need to assign the defined function to the attribute.
For example:
--------------------------------------------------------------------------------------------------------------------
import javafx.ui.*;

Frame{
title: "Example"
content: BorderPanel{
center: TabbedPane{
tabs: foreach(i in [1..5])
Tab {
title: "Tab{i}"
content: Label{ text: "Label{i} "}
}

onSelectionChange: operation(s1: SingleSelection, s2: SingleSelection){
System.out.println("selection changed: index {s1.anchorIndex} -> index {s2.anchorIndex} ");
}

}
}
visible: true
}
--------------------------------------------------------------------------------------------------------------------

ferdinandogranelli
Offline
Joined: 2007-11-20
Points: 0

Under Eclipse this Sample doesn't work .
add import java.lang.*;

Message was edited by: ferdinandogranelli