B4J Question How To Add Panel with Title in Border

Daestrum

Expert
Licensed User
Longtime User
Javafx has a TitledPane, but you probably need to use javaobject to create it. Also you probably need to set setCollapsible(False) so it cannot be collapsed.

api here https://openjfx.io/javadoc/13/javafx.controls/javafx/scene/control/TitledPane.html

a simple test
B4X:
#Region Project Attributes 
    #MainFormWidth: 600
    #MainFormHeight: 600
    #JavaCompilerPath: 16, D:\jdk-16.0.1\bin\
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI 
    Private Button1 As B4XView
    Dim b1 As Button
    Dim tp As JavaObject
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    b1.Initialize("b1")
    b1.PrefWidth = 100
    b1.PrefHeight = 20
    b1.Text = "myButton"
    tp.InitializeNewInstance("javafx.scene.control.TitledPane",Array("MyTitle",b1))
    tp.RunMethod("setCollapsible",Array(False))
    MainForm.RootPane.AddNode(tp,50,250,150,100)
End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello World!", "B4X")
End Sub
Sub b1_click
    Log("it works")
End Sub

It looks like this
1625606045361.png
 
Last edited:
Upvote 0
Top