Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2006, 07:49 AM
Authorized User
 
Join Date: Jan 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


 
Old July 6th, 2006, 07:01 AM
Authorized User
 
Join Date: Jan 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got it to work.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Video Stream Display using SWT nkrust Java GUI 1 June 9th, 2006 10:39 AM
Tabs dkr72 C# 1 December 3rd, 2004 02:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.