Results 1 to 10 of 10

Thread: SWT example

  1. #1
    Jyo
    Jyo is offline Member
    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Default SWT example

    import org.eclipse.swt.*;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.*;
    import org.eclipse.swt.widgets.*;

    public class FirstExample {
    public static void main(String[] args){
    Display firstDisplay = new Display();
    Shell firstShell = new Shell(firstDisplay);
    firstShell.setText("First Example");
    firstShell.setSize(200,100);
    firstShell.open ();
    while (!firstShell.isDisposed()) {
    if (!firstDisplay.readAndDispatch())
    firstDisplay.sleep ();
    }
    firstDisplay.dispose ();

    -------->final Button myButton = new Button(shell, SWT.PUSH);


    SelectionAdapter adapter = new SelectionAdapter() {
    public void widgetSelected(SelectionEvent event) {
    myButton.setText("You clicked me!");
    }
    };
    myButton.addSelectionListener(adapter);
    myButton.setText("Click");


    }
    }


    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    shell cannot be resolved

    at FirstExample.main(FirstExample.java:20)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default

    You don't have a variable named 'shell'; you do have one named 'firstShell' though ...

    kind regards,

    Jos

  3. #3
    Jyo
    Jyo is offline Member
    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Default Thanks Jos I appreciate ur help.

    Thanks jos again

  4. #4
    Jyo
    Jyo is offline Member
    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Default Need some help

    Hi Jos,

    I am new to Java,this is my first application. I am going to attach an screen in which my manager developed in VB6, he wants me to develop in Java. I am a .net programmer before, So am actually not getting anything. He wants me to develop this using SWT and I dont know what is RCP. He wants me to use that also.If you could please helkp with this I really appreciate ur help.

    Thanks a lot in advance
    Jyo
    Attached Thumbnails Attached Thumbnails SWT example-main-screen.jpg  

  5. #5
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    11

    Default

    create a new thread and post a bigger picture.

  6. #6
    Jyo
    Jyo is offline Member
    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Default Other look of the screen

    Hi,

    I hope u can see the screen now.

    Thank You.
    Attached Thumbnails Attached Thumbnails SWT example-main-screen.jpg  

  7. #7
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    11

    Default

    SWT is an open source widget toolkit for Java designed to provide efficient, portable access to the user-interface facilities of the operating systems on which it is implemented.

    and eclipse.org/articles/Article-RCP-1/tutorial1.html is a site with a tutorial for rcp.

  8. #8
    Jyo
    Jyo is offline Member
    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Default How to add submenu in main menu

    Hi All,

    I am developing a java application using SWT. In the top I created a tool bar menu, but am not able to create a submenu item in the main menu. I am going to post my code. If anybody can help me with this I appreciate ur help.

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.CTabFolder;
    import org.eclipse.swt.custom.CTabFolder2Listener;
    import org.eclipse.swt.custom.CTabFolderEvent;
    import org.eclipse.swt.custom.CTabItem;
    import org.eclipse.swt.graphics.Color;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Menu;
    import org.eclipse.swt.widgets.MenuItem;
    import org.eclipse.swt.widgets.Shell;

    public class CTabFolderCTabFolder2Listener {
    public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("QuiltCAD 3.x.x");

    shell.setLayout(new GridLayout(1, true));
    Listener showListener = new Listener() {
    public void handleEvent(Event event) {
    Menu menu = (Menu) event.widget;
    MenuItem item = menu.getParentItem();
    if (item != null) {
    System.out.println(item.getText());

    }
    }
    };
    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);
    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
    fileItem.setText("File");
    MenuItem editItem = new MenuItem(menuBar, SWT.CASCADE);
    editItem.setText("Edit");
    Menu subMenuItem = new Menu(shell, SWT.DROP_DOWN);
    fileItem.setMenu(subMenuItem);
    MenuItem selectMenuItem = new MenuItem(
    subMenuItem, SWT.NULL);
    MenuItem viewItem = new MenuItem(menuBar, SWT.CASCADE);
    viewItem.setText("View");
    MenuItem optionsItem = new MenuItem(menuBar, SWT.CASCADE);
    optionsItem.setText("Options");
    MenuItem layoutItem = new MenuItem(menuBar, SWT.CASCADE);
    layoutItem.setText("Layout");
    MenuItem helpItem = new MenuItem(menuBar, SWT.CASCADE);
    helpItem.setText("Help");
    Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
    fileMenu.addListener(SWT.Show, showListener);
    fileItem.setMenu(fileMenu);
    CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP);
    tabFolder.setBorderVisible(true);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Set up a gradient background for the selected tab
    tabFolder.setSelectionBackground(new Color[] {
    display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHA DOW),
    display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHA DOW),
    display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHAD OW) }, new int[] { 50, 100 });
    new CTabItem(tabFolder, SWT.NONE, 0).setText("QuiltCAD ");
    new CTabItem(tabFolder, SWT.NONE, 1).setText("PatternCAD ");
    new CTabItem(tabFolder, SWT.None,2).setText("QuiltLayout ");
    new CTabItem(tabFolder, SWT.None, 3).setText("Print Preview");
    new CTabItem(tabFolder, SWT.None, 4).setText("Optimizer");
    new CTabItem(tabFolder, SWT.None, 5).setText("QuiltMotion");
    new CTabItem(tabFolder, SWT.None, 6).setText("Import/Export");
    new CTabItem(tabFolder, SWT.None, 7).setText("Virtual Longarm");
    new CTabItem(tabFolder, SWT.None, 8).setText("Decorative Stitching");
    new CTabItem(tabFolder, SWT.None, 9).setText("Piecing");
    tabFolder.addCTabFolder2Listener(new CTabFolder2Listener() {

    public void close(CTabFolderEvent arg0) {
    System.out.println("close");

    }

    public void minimize(CTabFolderEvent arg0) {
    // TODO Auto-generated method stub

    }

    public void maximize(CTabFolderEvent arg0) {
    // TODO Auto-generated method stub

    }

    public void restore(CTabFolderEvent arg0) {
    // TODO Auto-generated method stub

    }

    public void showList(CTabFolderEvent arg0) {
    // TODO Auto-generated method stub

    }
    });

    shell.open();
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch()) {
    display.sleep();
    }
    }
    display.dispose();
    }

    }



    Thank You,
    Jyothi

  9. #9
    Jyo
    Jyo is offline Member
    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Default need some help again with my project

    HI All,

    As you can see in my previous threads I posted my code for the java app using SWT. I need some more help with that, I will be posting a screen on the top u can see Tool bar menu, u8nder that tabs, in the right hand side we have again tabs , buttons , drop down menu . How should I create that on the right side. In the down we have few buttons with the scroll bars. If anybody can please help me with the code, I am very thankful to you.

    Thanks a lot in advance

    Jyothi
    Attached Thumbnails Attached Thumbnails SWT example-main-screen.jpg  

  10. #10
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    11

    Default

    for big designing, use an ide :)
    it will safe you for much pain and thinking

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •