-
Bug
-
Resolution: Fixed
-
P4
-
fx2.0
-
JavaFX 2.0GA JDK7u2b8
Place a button in a TitledPane and it will fill the control.
Amy's comment onRT-17226 says "Buttons have a default max size clamped to their preferred size, which is why the buttons don't expand to fill the tiles by default. " However, in this case, the button does expand without unclamping the max size of the button.
As a workaround, you can put the button inside a StackPane inside the TitledPane and it won't resize itself.
Example attached.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TitledPaneWidthTest extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Titled Pane Width Test");
final Button b1 = new Button("Hit Me B1");
final TitledPane p1 = new TitledPane("Button should be skinnier", b1);
final StackPane stackPane = new StackPane();
final Button b2 = new Button("Hit Me B2");
stackPane.getChildren().add(b2);
final TitledPane p2 = new TitledPane("Button in StackPane so ok", stackPane);
// display the scene.
final VBox root = new VBox();
root.setSpacing(10);
root.getChildren().addAll(p1, p2);
Scene scene = new Scene(root, 500, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Amy's comment on
As a workaround, you can put the button inside a StackPane inside the TitledPane and it won't resize itself.
Example attached.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TitledPaneWidthTest extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Titled Pane Width Test");
final Button b1 = new Button("Hit Me B1");
final TitledPane p1 = new TitledPane("Button should be skinnier", b1);
final StackPane stackPane = new StackPane();
final Button b2 = new Button("Hit Me B2");
stackPane.getChildren().add(b2);
final TitledPane p2 = new TitledPane("Button in StackPane so ok", stackPane);
// display the scene.
final VBox root = new VBox();
root.setSpacing(10);
root.getChildren().addAll(p1, p2);
Scene scene = new Scene(root, 500, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
}