B4J Question setsize doesn't work

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello,
I am trying to set the size of a pane, at runtime, but for some reason it doesn't work.
what am I doing wrong ?


Code:
    ' ResolutionX and ResolutionY contain the screen and mainform resolution
    ' Caixa1 is a Pane created via Abstract Designer
    Dim SizeX as Double = ResolutionX / 5
    Dim SizeY as Double = ResolutionY / 5
    Caixa1.Top=0
    Caixa1.Left=0
    Caixa1.SetSize(SizeX,SizeY)
 
Try to use:
Code:
Dim SizeX as Double = ResolutionX / 5
Dim SizeY as Double = ResolutionY / 5
Caixa1.Top=0
Caixa1.Left=0
Caixa1.PrefWidth = SizeX '<-----
Caixa1.PrefHeight = SizeY '<-----
 
Upvote 0
Log SizeX and SizeY, to watch if are always the same value. Maybe the mistake is in resolution calculation

Nope. Not even checking the width and height in the designer and doubling it in the code.

Designer = 250 x 150
Code:
Caixa.Setsize(500,250)

Stays the same
 
Upvote 0
How you calculate ResolutionX and ResolutionY?

I use this code

Code:
Dim joForm As JavaObject = MainForm
joForm.GetFieldJO("stage").RunMethod("setMaximized", Array(True))
ResX=MainForm.Width
ResY=MainForm.Height

But as I wrote previously, even setting the size with fixed values doesn't resize
 
Upvote 0
Back
Top