B4J Question TagPane closing tabs and/or check for existing tab

Lahksman

Active Member
Licensed User
Longtime User
Basicly 2 small questions:
  • How can you close a tab previously created?
  • How can I check when a user tries to open a new tab, if this tab already exists?
    For example, the user already opened a product tableview but this tab is not active and he tries to open it again. How can I jump to the already opened tab.
Are these 2 things possible or is there any other library I can use. Haven't found one yet.
 

Lahksman

Active Member
Licensed User
Longtime User
I'm not closing them. I was looking for a way to close them.
But guessing from your reply it's not possible.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to allow the user to close tabs and find the tab that was closed:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private TabPane1 As TabPane
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1")
   MainForm.Show
   TabPane1.LoadLayout("2", "Tab 1")
   TabPane1.LoadLayout("2", "Tab 2")
   Dim jo As JavaObject = TabPane1
   jo.RunMethod("setTabClosingPolicy", Array("ALL_TABS"))
   Dim ev As Object = jo.CreateEventFromUI("javafx.collections.ListChangeListener", "TabsListChanged", Null)
   jo.RunMethodJO("getTabs", Null).RunMethod("addListener", Array(ev))
End Sub

Sub TabsListChanged_Event (MethodName As String, Args() As Object) As Object
   Dim jo As JavaObject = Args(0)
   jo.RunMethod("next", Null)
   Dim removed As List = jo.RunMethod("getRemoved", Null)
   Dim tp As TabPage = removed.Get(0)
   Log($"Tab: ${tp.Text} removed."$)
   Return Null
End Sub
 
Upvote 0
Top