Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access a component inside a Tab component

Tags:

codenameone

I'm new using Codename One. I'm doing an app which have a Form, that has a Tab component with 14 tabs inside, every tab has a gridlayout with 42 buttons, and I want to change a property in one button. The problem is that I don't know how to reach that button.

tabG.getContentPane().components.get(index)

tabG is the tab component, and I can reach the tab that I need, but after that I don't know how to reach the button index I want to change.

I tried

tabG.getContentPane().components.get(index).components.get(indexbutton)

But even can't compile this code.

enter image description here

I'll apprecciate any help.

like image 781
Alejandro Vargas Avatar asked Nov 07 '22 10:11

Alejandro Vargas


1 Answers

When you create the tab you need to prepare information to find the component later. E.g. if all tabs derive from the same class then just do something like:

MyBaseContainer cnt = (MyBaseContainer)tabs.getTabComponentAt(index);
Button theButtonINeed cnt.getMyImportantButton();

If this is more complicated you can use setName() or putClientProperty to prepare hints for you during form construction.

like image 156
Shai Almog Avatar answered Nov 11 '22 06:11

Shai Almog