FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
change size from content in tab
(add column / row zo gridPane)
dont update size from TabPane
onle add new Tab / switch to other triggers layout change
REGRESSION. Last worked in version 8u66
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
add Tab ([add Tab])
add Labels to Tab ([add Label])
-> add new Tab or switch to other Tab
-> TabPane change Width
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TabPaneLayoutMain extends Application {
private static final double MAX_VALUE = Double.MAX_VALUE;
private static final double USE_PREF_SIZE = Double.NEGATIVE_INFINITY;
private static final double USE_COMPUTED_SIZE = -1.0;
/**
* @param args
*/
public static void main(String[] args) {
launch(TabPaneLayoutMain.class, args);
}
@Override
public void start(final Stage stage) throws Exception {
final BorderPane root = new BorderPane();
final TabPane tabs = new TabPane();
tabs.setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
tabs.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
tabs.setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
BorderPane.setAlignment(tabs, Pos.TOP_LEFT);
final Button add = new Button("add Tab");
root.setTop(add);
add.setOnAction((event) -> tabs.getTabs().add(new AddTab()));
root.setCenter(tabs);
stage.setScene(new Scene(root, 800, 800));
stage.show();
}
private static final void changeTabPaneSize(final TabPane tabPane) {
final int index = tabPane.getSelectionModel().getSelectedIndex();
if (index < 0 || tabPane.getTabs().isEmpty()) {
return;
}
if (tabPane.getTabs().size() == 1) {
final Tab tab = tabPane.getTabs().remove(0);
tabPane.getTabs().add(tab);
} else if (tabPane.getTabs().size() > 1 && index == 0) {
tabPane.getSelectionModel().select(1);
} else if (tabPane.getTabs().size() > 1 && index != 0) {
tabPane.getSelectionModel().select(1);
}
tabPane.getSelectionModel().select(index);
}
private final class AddTab extends Tab {
private final int[] column;
private final GridPane grid;
private AddTab() {
super(String.valueOf(System.currentTimeMillis()));
this.column = new int[]{0};
this.grid = new GridPane();
this.grid.setHgap(4);
this.grid.setVgap(4);
this.grid.setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
this.grid.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
this.grid.setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
this.grid.getRowConstraints().add(new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE));
final Button add = new Button("add Label");
add.setOnAction((event) -> add(new Label("label")));
add(add);
setContent(this.grid);
}
private final void add(final Node node) {
GridPane.setConstraints(node, this.column[0]++, 0);
this.grid.getChildren().add(node);
this.grid.getColumnConstraints().add(new ColumnConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE));
if (getTabPane() != null) {
// workaround
// changeTabPaneSize(getTabPane());
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
private static final void changeTabPaneSize(final TabPane tabPane) {
final int index = tabPane.getSelectionModel().getSelectedIndex();
if (index < 0 || tabPane.getTabs().isEmpty()) {
return;
}
if (tabPane.getTabs().size() == 1) {
final Tab tab = tabPane.getTabs().remove(0);
tabPane.getTabs().add(tab);
} else if (tabPane.getTabs().size() > 1 && index == 0) {
tabPane.getSelectionModel().select(1);
} else if (tabPane.getTabs().size() > 1 && index != 0) {
tabPane.getSelectionModel().select(1);
}
tabPane.getSelectionModel().select(index);
}
A DESCRIPTION OF THE PROBLEM :
change size from content in tab
(add column / row zo gridPane)
dont update size from TabPane
onle add new Tab / switch to other triggers layout change
REGRESSION. Last worked in version 8u66
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
add Tab ([add Tab])
add Labels to Tab ([add Label])
-> add new Tab or switch to other Tab
-> TabPane change Width
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TabPaneLayoutMain extends Application {
private static final double MAX_VALUE = Double.MAX_VALUE;
private static final double USE_PREF_SIZE = Double.NEGATIVE_INFINITY;
private static final double USE_COMPUTED_SIZE = -1.0;
/**
* @param args
*/
public static void main(String[] args) {
launch(TabPaneLayoutMain.class, args);
}
@Override
public void start(final Stage stage) throws Exception {
final BorderPane root = new BorderPane();
final TabPane tabs = new TabPane();
tabs.setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
tabs.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
tabs.setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
BorderPane.setAlignment(tabs, Pos.TOP_LEFT);
final Button add = new Button("add Tab");
root.setTop(add);
add.setOnAction((event) -> tabs.getTabs().add(new AddTab()));
root.setCenter(tabs);
stage.setScene(new Scene(root, 800, 800));
stage.show();
}
private static final void changeTabPaneSize(final TabPane tabPane) {
final int index = tabPane.getSelectionModel().getSelectedIndex();
if (index < 0 || tabPane.getTabs().isEmpty()) {
return;
}
if (tabPane.getTabs().size() == 1) {
final Tab tab = tabPane.getTabs().remove(0);
tabPane.getTabs().add(tab);
} else if (tabPane.getTabs().size() > 1 && index == 0) {
tabPane.getSelectionModel().select(1);
} else if (tabPane.getTabs().size() > 1 && index != 0) {
tabPane.getSelectionModel().select(1);
}
tabPane.getSelectionModel().select(index);
}
private final class AddTab extends Tab {
private final int[] column;
private final GridPane grid;
private AddTab() {
super(String.valueOf(System.currentTimeMillis()));
this.column = new int[]{0};
this.grid = new GridPane();
this.grid.setHgap(4);
this.grid.setVgap(4);
this.grid.setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
this.grid.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
this.grid.setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
this.grid.getRowConstraints().add(new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE));
final Button add = new Button("add Label");
add.setOnAction((event) -> add(new Label("label")));
add(add);
setContent(this.grid);
}
private final void add(final Node node) {
GridPane.setConstraints(node, this.column[0]++, 0);
this.grid.getChildren().add(node);
this.grid.getColumnConstraints().add(new ColumnConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE));
if (getTabPane() != null) {
// workaround
// changeTabPaneSize(getTabPane());
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
private static final void changeTabPaneSize(final TabPane tabPane) {
final int index = tabPane.getSelectionModel().getSelectedIndex();
if (index < 0 || tabPane.getTabs().isEmpty()) {
return;
}
if (tabPane.getTabs().size() == 1) {
final Tab tab = tabPane.getTabs().remove(0);
tabPane.getTabs().add(tab);
} else if (tabPane.getTabs().size() > 1 && index == 0) {
tabPane.getSelectionModel().select(1);
} else if (tabPane.getTabs().size() > 1 && index != 0) {
tabPane.getSelectionModel().select(1);
}
tabPane.getSelectionModel().select(index);
}
- duplicates
-
JDK-8145495 Change content size in an Tab don't change size of parent TabPane
-
- Closed
-
-
JDK-8157400 TabPane dont update Size
-
- Closed
-
-
JDK-8172697 TabPane doesn't resize properly based on the content of its tabs
-
- Closed
-