|
|
Re: silly newbie question [message #444238 is a reply to message #444190] |
Sun, 10 October 2004 02:34 |
Vincent Jenks Messages: 27 Registered: July 2009 |
Junior Member |
|
|
Dominique Vlieghe wrote:
> See
> http://www.cs.umanitoba.ca/~eclipse/
> Tutorial 2, page 1
> Hope this helps
> Vincent Jenks wrote:
> > How do I simply launch one SWT shell window from another? I know how to
> > add the event to a button or another type of widget but how do I call
> > another window?
> >
Actually no, that doesn't explain it at all. That's a very vague
brushing-over of how it can be done but the code that was generated by the
Visual Editor isn't the same, it's done in VE using the open() method of
the shell rather than adding the display to the shell's constructor, which
would appear to limit my flexibility.
For example...
public static void main(String[] args)
{
Display display = Display.getDefault();
SnapMain thisClass = new SnapMain();
thisClass.createSShell();
thisClass.snapMainShell.open();
while (!thisClass.snapMainShell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
...createSShell() looks like this:
public void createSShell()
{
snapMainShell = new Shell();
button = new Button(snapMainShell, SWT.NONE);
snapMainShell.setSize(new org.eclipse.swt.graphics.Point(726, 538));
snapMainShell.setText("Snap Trials - Alpha Demo 0.1");
button.setBounds(new org.eclipse.swt.graphics.Rectangle(572, 10, 75,
24));
button.setText("Options");
button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter()
{
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
{
System.out.println("widgetSelected()");
launchOptionsMenu(); //!!
}
});
}
When I attempt to do it like this, calling another shell from within the
main window (widgetSelected event of a button, see above), the application
crashes:
private void launchOptionsMenu()
{
Display display = Display.getDefault();
OptionsMenu op = new OptionsMenu();
optionsShell = op.getSShell();
optionsShell.open();
optionsShell.dispose();
while (!optionsShell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
Can someone perhaps provide some URLs that may have actual code-examples
rather than one-liner explanations on how it's generally done?
I'm having a real hard time w/ this...and it's such a simple concept.
Thanks!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03451 seconds