Results 1 to 3 of 3

Thread: Basics

  1. #1
    avish12 is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Default Basics

    Hi, I'm new here :)
    first of all, can anyone point me to a specific code examples about Listeners and Shells?

    Now three questions:

    1. How do I open a shell inside a shell? i.e, I have the main shell in display and now wanting to open a Message-Box-like shell, that will contain a Text to get some string...
    So, I understand the creation, yet I can't find what to write as the part that makes the shell listen constantly. Meaning, what will I do that is similar to:

    Java Code:
        shell.open();
        // Set up the event loop.
        while (!shell.isDisposed()) {
          if (!display.readAndDispatch()) {
            // If no more entries in the event queue
            display.sleep();
          }
        }
        display.dispose();
    (The problem is of course that I DON'T have the "display" object, 'cause the parent here is the main shell...

    2. My main shell is defined where the main function is, yet I would like to pop a MessageBox somewhere else. How can I do it when I need to know what shell am I in?

    3. Assuming layoutData is of shell is defined as GridData, what determines whether information will be shown by rows or by coloumns?

    Thanks in advance,
    Avishay
    Last edited by Fubarable; 12-11-2009 at 02:39 PM. Reason: Code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    jagadeesh is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    Hi,
    use your shell as parent for your Messagebox.
    Example code is,
    Java Code:
    public class SWTApp {
    
    
    	public SWTApp(Display display) {
    
    	final Shell shell = new Shell(display);
    	shell.setText("Center");
    	shell.setSize(250, 200);
    	shell.open();
    	
    	shell.setMinimumSize(100, 100);
    	Button  button=new Button(shell,SWT.PUSH);
    	button.setBounds(100, 100, 300, 150);
    	button.setText("Click Me");
    	button.addSelectionListener(new SelectionListener(){
    
    		
    		public void widgetDefaultSelected(SelectionEvent arg0) {
    			
    			
    		}
    
    		
    		public void widgetSelected(SelectionEvent arg0) {
    			
    			MessageBox mb=new MessageBox(shell,SWT.OK|SWT.ICON_INFORMATION);
    			mb.setMessage("Hello welcome");
    			mb.setText("Hi");
    			mb.open();
    		}
    		
    		
    	});
    
    	while (!shell.isDisposed()) {
    	if (!display.readAndDispatch()) {
    	display.sleep();
    	}
    	}
    	}
    	public static void main(String[] args) {
    	Display display = new Display();
    	new SWTApp(display);
    	display.dispose();
    	}
    	}

Similar Threads

  1. Really Basics
    By Taluntain in forum New To Java
    Replies: 16
    Last Post: 10-08-2009, 09:43 AM
  2. Help in basics of database..
    By vinoth in forum JDBC
    Replies: 5
    Last Post: 09-08-2009, 07:01 PM
  3. About swing basics
    By harithaspa in forum AWT / Swing
    Replies: 2
    Last Post: 12-13-2008, 12:07 PM
  4. Basics of Servlet
    By pcvardhan in forum Advanced Java
    Replies: 1
    Last Post: 06-13-2008, 02:07 PM
  5. Basics
    By AKP in forum New To Java
    Replies: 7
    Last Post: 05-23-2008, 12:06 PM

Posting Permissions

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