Results 1 to 3 of 3

Thread: Basics

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

    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:;
        // Set up the event loop.
        while (!shell.isDisposed()) {
          if (!display.readAndDispatch()) {
            // If no more entries in the event queue
    (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,
    Last edited by Fubarable; 12-11-2009 at 03:39 PM. Reason: Code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

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


    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.setSize(250, 200);;
    	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");
    	while (!shell.isDisposed()) {
    	if (!display.readAndDispatch()) {
    	public static void main(String[] args) {
    	Display display = new Display();
    	new SWTApp(display);

Similar Threads

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