How to bind Pane with another Pane in JavaFX

后端 未结 1 701
野的像风
野的像风 2021-01-25 15:04

I\'m finding the way that how to bind the size of a pane with the outer pane.

I could bind the size ofRectangle with Pane, But couldn\'t bind an inner pane (Red dotted

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-25 15:54

    You do not need a binding to achieve this. The problem is the fact that you set the constraints for maxHeight/maxWidth to USE_PREF_SIZE, i.e. to a fixed value that can very well be reached when resizing the window. Remove those constraints to allow the AnchorPane to grow as necessary:

    Tab.fxml

    
        ...
    
    

    Furthermore I recommend avoiding the use of AnchorPanes, if you can avoid it. It's hard to achieve responsive layouts with this kind of layout. VBox and HBox would do much better jobs in this case.

    Example:

    
    
    
    
    
    
    
    
    
    
    
    
    
        
            
        
        
            
            
            
                
                    
                
                
                    
                        
                            
                        
                    
                    
                    
                    
                    
                     
                    
                
            
        
    
    

    0 讨论(0)
提交回复
热议问题