B4J Question TabPane problem

micro

Well-Known Member
Licensed User
Longtime User
I have a TabPAne named Tabmain with four TabPage ("tab1", "tab2", "tab3", "tab4") designed with javafx scene builder.
If in my code insert this:
B4X:
Log(Tabmain.Tabs.Get(0)) 'first TabPage = "tab1"

The program crash with this log:

Error occurred on line: 122 (main).
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:208)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:469)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:209)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:153)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:69)
at anywheresoftware.b4a.BA$2.run(BA.java:162)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)


How i can get the name of each Tabpages?

Another question:
How i can set for default the second (or another) Tabpage?

Thanks
 

stevel05

Expert
Licensed User
Longtime User
This works for me with B4j V1.50:

B4X:
Dim T As TabPage = TabMain.Tabs.Get(0)
    Log(T.Text)

What version of B4j are you using?

You can set the selected TabPage using:

B4X:
TabMain.SelectedIndex = 1
for page 2.
 
Upvote 0

karelespinoza

New Member
Licensed User
Longtime User
Hola por favor ayuda con el uso de TabPane cada uno con su propio modulo, como llamo al modulo y este a la vez al layaut correspondiente. Gracias
Tengo 5 Code Module y con cada uno de ellos tengo un layout lo que quisiera es ocupar el TabPane.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hola!

recuerda que tienes el foro en español:
https://b4x.com/android/forum/forums/spanish-forum.12/

Donde tambien se pueden resolver problemas de B4J.

para tu duda:

Creas una instancia de TabPage, la inicializas
Creas una instancia de PInterno que va a fungir como el panel interno del TabPage
El Panel lo pones como content de la TabPage
y con eso ya puedes hacer un loadLayout.
Por ultimo, mete el TabPage al TabPane
B4X:
        Dim menuPage As TabPage
        menuPage.Initialize
        Dim pInterno As Pane
        pInterno.Initialize("")
    
        menuPage.Content = pInterno

        menuPage.Text = "Información"
        menuPage.Content.LoadLayout("layoutinformacion")

        principalTab.Tabs.Add(menuPage)

Si tienes mas dudas puedes mandarme un Mensaje privado o hacer tu pregunta en el de español.
 
Upvote 0
Top