Search in sources :

Example 1 with TabPaneSelectionListener

use of org.apache.pivot.wtk.TabPaneSelectionListener in project pivot by apache.

the class Pivot751WithoutGUI method main.

public static void main(String[] args) {
    final TabPane tabPane = new TabPane();
    tabPane.getTabPaneSelectionListeners().add(new TabPaneSelectionListener() {

        @Override
        public void selectedIndexChanged(TabPane tabPaneArgument, int previousSelectedIndex) {
            System.out.println(String.format("tabs     : %-16d actual selectedIndex    : %d", tabPaneArgument.getTabs().getLength(), tabPaneArgument.getSelectedIndex()));
            System.out.println(String.format("indirect : %-16s 'previousSelectedIndex' : %d", (previousSelectedIndex == tabPaneArgument.getSelectedIndex()), previousSelectedIndex));
        }
    });
    System.out.println("Empty TabPane sequence");
    System.out.println(String.format("tabs     : %-16d actual selectedIndex    : %d", tabPane.getTabs().getLength(), tabPane.getSelectedIndex()));
    System.out.println("\nAdding first Label to the sequence");
    tabPane.getTabs().add(new Label("1"));
    System.out.println("\nAdding second Label at the end of the sequence");
    tabPane.getTabs().add(new Label("2"));
    System.out.println("\nInserting third Label at the start of the sequence");
    tabPane.getTabs().insert(new Label("3"), 0);
    System.out.println("\nAdding a fourth Label at the end of the sequence");
    tabPane.getTabs().add(new Label("4"));
    System.out.println("\nExplicitly select the last tab");
    tabPane.setSelectedIndex(3);
    System.out.println("\nRemoving the first 2 Labels from the start of the sequence");
    tabPane.getTabs().remove(0, 2);
    System.out.println("\nRemoving the tab at the end of the sequence");
    tabPane.getTabs().remove(1, 1);
}
Also used : TabPane(org.apache.pivot.wtk.TabPane) TabPaneSelectionListener(org.apache.pivot.wtk.TabPaneSelectionListener) Label(org.apache.pivot.wtk.Label)

Aggregations

Label (org.apache.pivot.wtk.Label)1 TabPane (org.apache.pivot.wtk.TabPane)1 TabPaneSelectionListener (org.apache.pivot.wtk.TabPaneSelectionListener)1