SWT: Tabs and Labels
Hi,
i am new to SWT and am trying to build a form with two tabs. the problem i am having is how to display certain information depending on which tab is picked. for example if they choose TAB1 then they get a button saying Open and a label saying "enter first name". however if they pick TAB2 it will display a button saying Close and a label saying "enter address". but when i put in the label code the "enter first name" label gets displayed no matter what tab i select and it also places the label inside the button making the button huge. can anyone please help me. i have attached the code i am using now.
thanks in advanced
scoobie
Code ***********************
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class BuildTimeLine
{
public static void main (String [] args)
{
Display display = new Display ();
final Shell shell = new Shell (display);
final TabFolder tabFolder = new TabFolder (shell, SWT.BORDER);
/* TAB 1 AND CONTENT */
Label label1 = new Label(tabFolder, SWT.BORDER);
label1.setText("Enter first name");
label1.setSize(100,20);
label1.setLocation(100,450);
TabItem item1 = new TabItem (tabFolder, SWT.NONE);
item1.setText ("TAB1");
Button button1 = new Button (tabFolder, SWT.PUSH);
button1.setText ("Open");
item1.setControl (button1);
/* TAB 2 AND CONTENT */
Label label2 = new Label(tabFolder, SWT.BORDER);
label2.setText("Enter address");
label2.setSize(100,20);
label2.setLocation(50,500);
TabItem item2 = new TabItem (tabFolder, SWT.NONE);
item2.setText ("TAB2");
Button button2 = new Button (tabFolder, SWT.PUSH);
button2.setText ("Close ");
item2.setControl (button2);
tabFolder.pack ();
shell.pack ();
shell.setText("TEST");
shell.setSize(1200, 650); // setSize(w, h)
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}// end main method
}// end class
|