Results 1 to 3 of 3
Thread: Basics
- 12-11-2009, 02:10 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 1
- Rep Power
- 0
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:
(The problem is of course that I DON'T have the "display" object, 'cause the parent here is the main shell...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();
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,
AvishayLast edited by Fubarable; 12-11-2009 at 02:39 PM. Reason: Code tags added
-
Code tags added to make posted code retain its formatting and be more readable.
- 06-09-2010, 03:04 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 3
- Rep Power
- 0
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
-
Really Basics
By Taluntain in forum New To JavaReplies: 16Last Post: 10-08-2009, 09:43 AM -
Help in basics of database..
By vinoth in forum JDBCReplies: 5Last Post: 09-08-2009, 07:01 PM -
About swing basics
By harithaspa in forum AWT / SwingReplies: 2Last Post: 12-13-2008, 12:07 PM -
Basics of Servlet
By pcvardhan in forum Advanced JavaReplies: 1Last Post: 06-13-2008, 02:07 PM -
Basics
By AKP in forum New To JavaReplies: 7Last Post: 05-23-2008, 12:06 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks