2

I have a TabPane with multiple tabs inside a dialog . Within each of the tabs sits a pane with a different default size. I don't want to set the min, max, or pref size as I want my application to layout the pane automatically and hence deal effectively with different DPI screens. The issue is that I want to resize tab pane and hence dialog every time a select a tab, instead of the tab pane simply being the size of the biggest content pane. So for example if 'Tab 1' has a content pane with a default layout which ends up making it 300x300 pixels then on clicking 'Tab 1' I want the TabPane and then dialog to resize to 300x300.

e.g something like

private void addTabListeners(){
    for (int i=0; i<pamTabbedPane.getTabs().size(); i++){
        final int n=i; 
        pamTabbedPane.getTabs().get(i).setOnSelectionChanged((value)->{
            System.out.println("Tab selected "+pamTabbedPane.getTabs().get(n).getText());

            /**
             * Find default size of content pane 
             */
            double defualtHWidth=pamTabbedPane.getTabs().get(n).getContent().....
            double defualtHeight=pamTabbedPane.getTabs().get(n).getContent().....
            /*******************************/

            pamTabbedPane.setPrefSize(defualtHWidth, defualtHeight);
            Stage stage = (Stage) pamTabbedPane.getScene().getWindow();
            stage.sizeToScene();
        });
    }
}

This is a problem I come across quite a lot in different layout problems so any advice on how to approach it without resorting to manually setting size would be much appreciated.

Jamie Macaulay
  • 794
  • 6
  • 20
  • windows with jumping sizes are a horrible user experience - so _why_ do you want to annoy your users so much? – kleopatra Sep 03 '15 at 08:23
  • 1
    For this particular example you might be right- but really I'm more interested in being able to figure out what the default layout size for a pane- this was just a good example to explain what I meant. – Jamie Macaulay Sep 03 '15 at 08:54

0 Answers0