B4J Question view exceeds / overlap container border

a n g l o

Active Member
Licensed User
Longtime User
B4X:
Sub Process_Globals
        Private fx As JFX
        Private frm As Form
        Private pane1 As Pane
        Private lbl As Label
End Sub

Sub AppStart (Form1 As Form, Args() As String)
        frm.Initialize("frm",600,600)
        pane1.Initialize("pane1")
        pane1.Style="-fx-background-color: yellow;"
        frm.RootPane.AddNode(pane1,150,150,300,300)
        lbl.Initialize("lbl")
        lbl.Style="-fx-background-color: cyan;"
        pane1.AddNode(lbl,-150,0,300,20)
        frm.Show
End Sub

run this code. the outcome is a view(lbl) that exceeds /overlap the container border.
my target is that the part of the view(lbl) that is out of the container boundaries will not be seen, but still, keep the view(lbl) size unchanged.
in vb6, what i'm after is the default behavior.
HowTo ?
Thank you
 

Cableguy

Expert
Licensed User
Longtime User
Why do you set the label color using css?
You can set it directly using lbl.color. By setting it using css you are overriding the default behavior.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Many mistakes in this short code.

1. Do whatever you can with the designer. This is especially important in B4J (and B4i).
2. Never set the style like this. Use CSSUtils.
3. Use B4XView whenever you can. You will never see new code of mine with Pane.
4. Set the color with B4XView.Color = XUI.COLORS_YELLOW
5. If you want to create a panel programmatically then do it with XUI.CreatePanel:
B4X:
Dim pnl As B4XView = XUI.CreatePanel("pane1")
It will clip the child views.
 
Upvote 0

a n g l o

Active Member
Licensed User
Longtime User
Thank you ! i've tested each issue alone to find what makes the different on the screen.
using XUI panel made the change.
of course i'll follow everything else where possible.
Thanks again !
 
Upvote 0
Top