Peter Penzov
Peter Penzov

Reputation: 1588

Close all tabs in TabPane

I have this code this is very basic and it's used to close all tabs in a TabPane.

MenuItem item4 = new MenuItem("Close All Tabs");
    item4.setOnAction(new EventHandler<ActionEvent>()
    {
        @Override
        public void handle(ActionEvent e)
        {
            System.out.println("Close All Tabs");
            int ee = tabPane.getTabs().size();
            tabPane.getTabs().remove(0, ee);
        }
    });

I want to optimize this part of the code:

        int ee = tabPane.getTabs().size();
        tabPane.getTabs().remove(0, ee);

Is there any other clear and optimized solution?

Upvotes: 1

Views: 2396

Answers (1)

Uluk Biy
Uluk Biy

Reputation: 49185

Maybe

tabPane.getTabs().clear();

Upvotes: 6

Related Questions