B4J Question Control movement during panel resizing

ValDog

Active Member
Licensed User
Longtime User
I have three buttons in a row in an anchorpane. When i resize the pane I would like the middle button to move proportionally (left/right, up/down) without changing size. How would I set the anchors to do this?

On a related issue, how can I restrict the anchorpane to movement in only one plane (up/down or right/left)?
 

BPak

Active Member
Licensed User
Longtime User
I have three buttons in a row in an anchorpane. When i resize the pane I would like the middle button to move proportionally (left/right, up/down) without changing size. How would I set the anchors to do this?

On a related issue, how can I restrict the anchorpane to movement in only one plane (up/down or right/left)?

In the Designer:

Place the Three buttons on AnchorPane.
Select the Three Buttons
Click Arrange in the Menu.
Select Wrap In GridPane
Size the GridPane on the AnchorPane
Select each button and put in its Width and Height and Text in the Properties Section
Also put in the ID for each button
Select the GridPane and under Layout Click the Left and Right Constraints
This keeps the GridPane the same width as theOverall Pane.
Select the Left Button and in the Layout select the Halignment and select LEFT.
Select the Center Button and in the Halignment select CENTER
Select the Right Button and in the Halignment select RIGHT.

Click Preview in the Menu.
Select Show Preview in Window.
Re-size the Form and notice the Buttons change Position.

Code attached

You should be able to work out the rest from here.
 

Attachments

  • Design1.PNG
    Design1.PNG
    126.8 KB · Views: 391
  • CenterBtns.zip
    1.3 KB · Views: 293
Upvote 0

ValDog

Active Member
Licensed User
Longtime User
BPak, thanks - that works great! Also works for centering a single button as well.

Going back to my original query, how do I restrict resizing of the anchorpane to movement in only one plane?
 
Upvote 0

BPak

Active Member
Licensed User
Longtime User
Controlling the pane sizing can be done in the code in Sub AppStart

B4X:
    MainForm.SetWindowSizeLimits(MainForm.WindowWidth, MainForm.WindowHeight, _
                MainForm.WindowWidth + 100.0, MainForm.WindowHeight + 80.0)

That code allows the width to be changes to an extra 100 and the Height to an extra 80.
MainForm.WindowHeight + 80.0 could be set as MainForm.WindowHeight and the Height of the Window remains unchangeable.
 
Upvote 0
Top