HI.. i have this piece of code in java...
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class testTabs {
static int count;
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("SWT TabFolder Example");
CTabFolder folder = new CTabFolder(shell,SWT.NONE);
CTabItem item = new CTabItem(folder,SWT.UP);
item.setText("First");
CTabItem item1 = new CTabItem(folder,SWT.UP);
item1.setText("First new");
//---------------------------------------------------
CTabFolder fold = new CTabFolder(folder,SWT.UP);
CTabItem ite = new CTabItem(fold,SWT.UP);
ite.setText("Second");
final Composite test = new Composite(fold,SWT.NONE);
test.setLayout(new RowLayout());
Text tab1 = new Text(test,SWT.NONE);
tab1.setText("Testing");
tab1.setEditable(true);
ite.setControl(test);
item.setControl(fold);
Button add = new Button(test,SWT.PUSH);
add.setText("ADD");
SelectionAdapter adap = new SelectionAdapter(){
public void widgetSelected(SelectionEvent e){
Composite newcomp = new Composite(test,SWT.BORDER_DASH);
Text testtext = new Text(newcomp,SWT.BORDER_SOLID);
testtext.setText("Inside new Comp");
count++;
System.out.println(count);
Control array[] = shell.getChildren();
System.out.println(array.length);
shell.pack();
}
};
add.addSelectionListener(adap);
shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch()){
display.sleep();
}
}
}
}
When i run this, the composite "newcomp" is not visible.. can anyone help me??