Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » get a widget contained in a tab
get a widget contained in a tab [message #1727350] Tue, 22 March 2016 11:07 Go to next message
François Irhy is currently offline François IrhyFriend
Messages: 2
Registered: March 2016
Junior Member
Hi, I have a tab in which I publish a list. I would like to be able to access and modify my list from the tab.

For example please see that code bellow :

        public void createControl(Composite parent) {
                Composite container = new Composite(parent, SWT.NULL);
                GridLayout layout = new GridLayout(3, false);
                container.setLayout(layout);
                tabfolder = new CTabFolder(container, SWT.BORDER | SWT.MULTI);
                CTabItem tab= new CTabItem(tabfolder, SWT.CLOSE);
                tab.setControl( createTabContent( tabfolder ));
        }

private Composite createTabContent( Composite parent ) {
                Composite c = new Composite( parent, SWT.NONE );
                c.setLayout( new GridLayout( 2, false ));
                List list=new List(c, SWT.MULTI | SWT.V_SCROLL);
                GridData gd = new GridData();
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessVerticalSpace = true;
                list.setLayoutData(gd);
                for (int i=0; i<3; i++) list.add ("Item " + i);
                return c;
        }


Is there a way to access and modify the list from the tab ?

for example :

List myList = (List) tab.function_to_access_list()


Thanks for your help

Re: get a widget contained in a tab [message #1727399 is a reply to message #1727350] Tue, 22 March 2016 17:33 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 694
Registered: January 2012
Senior Member

CTabItem#getControl() will return the control that you set with #setControl(). But you should hold on to your list in a field.

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:SWT Tree item and subitem Layer level
Next Topic:Need to have Copy and paste feature in SWT Table to clipboard/other table
Goto Forum:
  


Current Time: Fri Dec 15 21:22:18 GMT 2017

Powered by FUDForum. Page generated in 0.01358 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software