I created a FXML file using JavaFX Scene Builder 1.1. An AnchorPane is created by default. Why can't I modify the resizable attribute?
Do you want to disable window resizing? If so, you can do that in your application program:
stage.setResizable(false);
Why you can't edit bounds
Checkout the javadoc on layoutBounds and boundsInLocal. You will notice that both are ReadOnlyObjectProperties, which is why you can't directly modify them in SceneBuilder.
How to resize a node in SceneBuilder
You can indirectly effect the bounds properties and directly set the resizable properties of the node by altering the min, pref and max height and width.
You can also set the pref size by selecting the pane to be resized and dragging the resizing anchors the surround the selected pane.
Further Information
You might want to read the Oracle tutorial on Tips for Sizing Nodes and Amy Fowler's presentation on JavaFX layout.
You can change resizeble using code
primaryStage.setResizable(false);
Related
I'm building a JavaFX desktop app using scenebuilder for the UI.
Here i have a tilepane inside of a scrollpane, i couldnt use the "fit to parent" option from the context menu in scene builder, i guess the solution is to give them -fx-id's and bind their width in the controller ?
I dont want to use any values so it all comes together nice when the user resizes the window.
how should i go about doing this?
I am making a view in SceneBuilder for my JavaFX application. I want my view to be maximized. How can I achieve this in SceneBuilder or the .fxml file?
You cannot do that using Scene Builder, since maximize or fullScreen are properties of the Stage and not the layouts set on the scene.
You can load and set the .fxml on the scene and later set the scene on the stage.
The following methods can be used on the stage :
setMaximized(boolean) - To maximize the stage and fill the screen.
setFullScreen(boolean) - To set stage as full-screen, undecorated window.
As you cannot maximize your view in fxml, you have to set the size of the stage to be maximized. There is no direct method for setting the size of the stage to be maximized in javafx 2 but there is another way you can do this. It is by manually setting the size of the stage. You can use this code:
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
This is the code that works for me
primaryStage.setMaximized(true);
it miximizes my window screen on the launch of the app.
I agree with Yemmy1000. primaryStage.setMaximized(true) works fine for me.
primaryStage.setScene(new Scene(root, 1800, 850));
primaryStage.setMaximized(true);
This code will go to width: 1800 and height:900 when restored down from maximum.
Two properties I found in stage which are useful.
First is setFullScreen(boolean) which will set your view to full screeb, but it will also hide all the taskbar and header of view.
Second is setMaximized(boolean) which will set you view to perfect like any other application view size.
I an using setMaximized(true) for my application.
I got the task to draw some points on a map. Wrote some code but currently every point I create via shapes will be added to the wrong position inside of my gridpane. Oh and I'm using JavaFX.
I added an imageView to the index 0,0 of my GridPane and every point is created through x and y position of the MouseEvent on the imageView.
After that I added the created point as a child of the GridPane and it's displayed at the center of the y-axis of the first grid.
Tried different things like anchorPanes and canvas but can't seem to get it working.
Code of my View:
http://pastebin.com/dCb7EN4d
Code of my Main:
http://pastebin.com/vp5tzxkG
I hope that's enough ^^'
pls help!
Greetings,
Ben
GridPane is a managed layout: it will position nodes that are added to it via the properties you set (using defaults if you don't set them). So when you add your circles to the grid pane, since you don't set any properties, it will place it in cell (0,0) and align it within that cell using default settings; i.e. it ignores the centerX and centerY properties.
What you should really do here is use a layout that does not manage the positioning of the nodes for you, such as a Pane (or possibly a Group). You can put the ImageView and the Circles in the pane, and then place the pane in the rest of your layout (in the scroll pane, I think).
The other option you have is to call setManaged(false) on the nodes you add to the GridPane in order to instruct the GridPane not to position them, though this feels like more of a workaround.
TextField t1 = new TextField();
t1.setMaxHeight(50);
t1.setMaxWidth(140);
This is the code I use to define a TextField in JavaFX. I think setMaxHeight() method is not working because size is not changing even if the value is changed.
So I tried setPrefSize(), but it too has a problem. The height property is working fine in it, but width is larger than I specified.
How to solve the above issue ?
This is very similar to how swing components work with a layout manager. In javafx the parent pane will adjust the size of nodes so a size that fits. I bet if you give the pane more room the nodes will fill out to their preferred size.
I´m using JavaFX scene builder now for the first time and I´m wondering if there is any fill_parent setting to let for example the menu bar always have the size of it´s parent, even if the window is rescaled by code.
Is there any appproach to have such a behavior in the designer?
There is the function "Fit To Parent" that can be found by right-clicking on an element in a container. This function is not available for all containers, what container do you want to fill?