Resize JavaFX tab when double click

前端 未结 2 1658
有刺的猬
有刺的猬 2020-12-21 08:11

I have this simple example with JavaFX tabs:

    public class test extends Application
{

    private BorderPane root;

    // Navigation Utilization
    pri         


        
2条回答
  •  心在旅途
    2020-12-21 08:16

    You required to add few lines to your code, here is a sample for you,

    .....
    
    Tab tabA = new Tab();
    
    Label tabALabel = new Label("Main Component");
    tabA.setGraphic(tabALabel);
    
    tabALabel.setOnMouseClicked(new EventHandler() {
        @Override
        public void handle(MouseEvent mouseEvent) {
            if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
                if (mouseEvent.getClickCount() == 2) {
    
                    mainPane.setPrefSize(500, 500); //Your required size
    
                }
           }
        }
    });
    
    ....
    

    Try this, and tell if there's any difficulty.

提交回复
热议问题