B4J Question [SOLVED] TabPane opened step-by-step with Buttons - How to?


Well-Known Member
Licensed User
Hello community,

i have an example with 3 Tabs, but i don't want to open all Tabs at once.
They should be opened step-by-step with a Button_Click (forwards and backwards).

The problem is that the Tabs are opened more than one time, so i have several times opened Tab1 ...
How can i prevent the Tabs opening for more than one time (once)?
Attached is an example ...



Well-Known Member
Licensed User
try this - (although personally I would add all the tabs before displaying tabpane and just have 2 buttons forward and back - with back disabled on first page and forward disabled on last page)

Sub Process_Globals
 Private fx As JFX
 Private MainForm As Form
 Private TabPane1 As TabPane
 Private Button1 As Button
 Private Button2 As Button
 Private Button3 As Button
 Private Pane1 As Pane
 Private Pane2 As Pane
 Private Shown1,Shown2,Shown3 As Boolean  ' <<<<<<<<<<<<<<< new bit
End Sub
Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "TabPane.css"))
 TabPane1.LoadLayout("2", "Tab 1")
End Sub
Sub Button1_Click  'forward to Tab 2
 If Shown2=False Then
  TabPane1.LoadLayout("3", "Tab 2")
 End If
 TabPane1.SelectedIndex = 1
End Sub
Sub Button2_Click  'back to previous
 If Shown1=False Then 
  TabPane1.LoadLayout("2", "Tab 1")
 End If
 TabPane1.SelectedIndex = TabPane1.SelectedIndex - 1
End Sub
Sub Button3_Click  'forward to Tab 3
 If Shown3=False Then
  TabPane1.LoadLayout("3", "Tab 3")
 End If
 TabPane1.SelectedIndex = 2
End Sub