java - How to to allow an element's size (for example, a HBox) grow (overflow) outside the stage it belongs to -
is possible allow element's size (for example, hbox) grow (overflow) outside stage belongs to, while still being visible, , if so, how can go it?
wrap pane in group, not resizable scene. in following example, if comment out current root.setcenter(...) , uncomment 1 adds hbox, hbox constrained size of scene (so labels squeezed smaller , smaller add more of them).
when wrapped in group, hbox grow indefinitely.
import javafx.application.application; import javafx.scene.group; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.label; import javafx.scene.layout.borderpane; import javafx.scene.layout.hbox; import javafx.stage.stage; public class growinghboxtest extends application { int count = 0 ; @override public void start(stage primarystage) { hbox hbox = new hbox(); button button = new button("new label"); button.setonaction(e -> hbox.getchildren().add(new label("label "+(++count)))); hbox.setmaxwidth(double.max_value); borderpane root = new borderpane(); root.setbottom(button); // not grow outside of scene bounds: root.setcenter(hbox); // grow outside of scene bounds: // root.setcenter(new group(hbox)); primarystage.setscene(new scene(root, 400, 400)); primarystage.show(); } public static void main(string[] args) { launch(args); } }
Comments
Post a Comment