Scaling of group in borderpane center - javafx-2

Following Scenario:
BorderPane
center
ScrollPane
List of other nodes
The ScrollPane resizes niecely to fill all the space.
Adding a Group to the picture:
BorderPane
center
Group
ScrollPane
List of other nodes
Now the group has the size of the first Element in the ScrollPane and right of it, the space is left empty.
None of the nodes has any size attribute set (prefWidth,...). Neither in the fxml, nor in the code.
Any Idea, what could be wrong?

Related

How do I create the center of TouchScreenButton texture in the center of the TouchScreenButton position along with it's shape?

So, if I create a button using TouchScreenButton and assign a texture to it, the texture will be displayed on the left bottom of the TouchScreenButton position (See image below)
The TouchScreenButton position is in the top left corner of the rectable
When I don't assign a texture and instead I create a sprite as the child node and assign a texture to it, it will display the texture in the center of TouchScreenButton.
But the shape is still follows what I have said earlier.
My question, How do I create the center of TouchScreenButton texture in the center of the TouchScreenButton position along with it's shape? I want the TouchScreenButton is in the middle of the TouchScreenButton texture.
Solution 1. Go to your Sprite node and in the inspector disable Centered property in the offset section. This way though you should keep sprite and shape sizes for centers of the area and the texture to match, coz now both the Sprite and Shape will be to the right bottom of the origin coordinates of the button.
Solution 2. Go to your TouchScreenButton node and in the inspector enable Shape Centered property in the main section. This way you will make both the shape and the sprite to be centered in the origin of the button.

Codename one - scrollable layout restrictions

I have done my own version of the PropertyCross Demo (provided in their demo section).
The problem I currently face is the size of the "Recent Search" area. While I have a non-scrollable container, I can easily define the preferred height. As the Box Layout adheres to the preferred size, all is well, with the little issue of not being able to scroll it and see more than one result:
recentSearchContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS)); recentSearchContainer.setPreferredH((int)(this.getContentP‌​ane().getHeight() * 0.1f));
Once I set the container to scrollable, the preferred height gets overwritten and takes up as much space as it needs, taking too much space from the BorderLayout Center piece above it.
How to manipulate the preferred size of scrollable components?
You don't manipulate the preferred size. Scrollables take up more space so if you need them to take up a specific amount of space you need to use the right type of layout which in this case might not be border layout...
Border layout gives NORTH/SOUTH elements their preferred height which might not be what you want. You might want a grid layout which will divide the height 50/50. You might want a table layout where you can define the height in percentages etc.
For those who are interested, here is the solution:
Setup a table layout with a single column and as many rows as you need (similar to box layout y axis or border layout which only north, center and south).
Set the table layout to non-scrollable so it defaults to 100% of your screen.
add the components with height % of the screen they should take up.
those components can be scrollable and will still stick to the height constraint!
// inside a form object, setup the layout
TableLayout tl = new TableLayout(3, 1);
tl.setGrowHorizontally(true);
setScrollable(false);
setLayout(tl);
...
// and add stuff to it
add(tl.createConstraint().heightPercentage(15), labelDesc);
add(tl.createConstraint().heightPercentage(50), compGroup);
add(tl.createConstraint().heightPercentage(35), recentSearchContainer);
Works like a charm!

ScrollPane with preferedViewportWidth matching preferedWidth of content

I have a bunch of regions which have a specific preferedWidth set. These Regions are reused visual components in a drag and drop UI.
I want to create a conatainer of these regions and tried to accomplish this with a ScrollPane with an embedded VBox. I want the scrollpane to be wide enough to hold the VBox without horizontal scrolling.
I could figure out the width of the VBox by hand and hardcode the scrollbars width but i would prefere a dynamic solution so that i can style the vbox later. Unfortunately the vbox preferred width is -1 even though its children have a prefered width set.
Also if i try to set the scrollpanes preferedViewportWidth to the width of my regions i get mixed results dependent on the hbarPolicy. If the policy is set to AS_NEEDED the width of the scrollbar is ignored and the scrollbar appears over my regions when it appears.
Any ideas how i get a SrollPane which is wide enough for my regions with and without a vertical scrollbar and possible styling of paddings etc.
Solved my problem by binding the ScrollPane's prefViewportWidthProperty() to the width property of the child.

Viewport of a scene region in Java Fx

i have a JavaFx scene with a Region element as ist parent element. Lets say I want this region to have a defined size of 20.000x20.000 Pixels, but Only a window of the size 1024x768.
How can I make my scene display the region area from x-pixel 5.000 and y-pixel 3.000, just similar to a Viewport of the ImageView class? Is this even possible?
Place your Region in a ScrollPane.

Even distribution of views in a layout

Is there any way, I can add UI components (Buttons in my case) to any layout (RelativLayout in my case) and width of parent gets evenly distributed among all views.
say parent width = 100;
if I add 10 Buttons - all buttons should be of width 10.
thanks.
m
If you use a LinearLayout you can make use of layout_weight to evenly distribute the size.
For eg, if you have two buttons, to take half width each of its parent, you can give "layout_weight=1" in both the buttons. So both of them would share the space.
Checkout the layout_weight documentation for more details

Resources