Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » open a SWT form from another SWT form
open a SWT form from another SWT form [message #462517] Thu, 13 October 2005 11:31
Jose is currently offline JoseFriend
Messages: 51
Registered: July 2009
Member
Hi all

I created two SWT forms, using the VE editor class. But I did not see
anywhere a place where the explain how to open a form from another form.

I have two forms:
- "one" that has only a button,
- "two", that has a lable that says "Hell World!!!"

How do I open form "two", from form "one"?

Am I missing something?

Is there any simple tutorial that explains this things, I was not able to
find an explanation on the net.


Here is the source code:


------------------------------------------------ form "one"
package first;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;

public class one {

private Shell sShell = null;
private Button btnOpen = null;

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/* Before this is run, be sure to set up the launch configuration
(Arguments->VM Arguments)
* for the correct SWT library path in order to run with the SWT dlls.
* The dlls are located in the SWT plugin jar.
* For example, on Windows the Eclipse SWT 3.1 plugin jar is:
* installation_directory\plugins\org.eclipse.swt.win32_3.1.0.j ar
*/
Display display = Display.getDefault();
one thisClass = new one();
thisClass.createSShell();
thisClass.sShell.open();

while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell();
sShell.setText("Shell");
sShell.setSize(new Point(300, 200));
btnOpen = new Button(sShell, SWT.NONE);
btnOpen.setBounds(new org.eclipse.swt.graphics.Rectangle(94,31,103,33));
btnOpen.setText("Open Form");
btnOpen.addSelectionListener(new
org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
System.out.println("widgetSelected()"); // TODO Auto-generated Event
stub widgetSelected()


}
});
}

}




--------------------------------------- form "two"
package first;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;

public class two {

private Shell sShell = null;
private Label lblTwo = null;

public two() {
super();
// TODO Auto-generated constructor stub
}

/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new Shell();
sShell.setText("Shell");
sShell.setSize(new Point(300, 200));
lblTwo = new Label(sShell, SWT.NONE);
lblTwo.setBounds(new org.eclipse.swt.graphics.Rectangle(55,21,186,44));
lblTwo.setFont(new Font(Display.getDefault(), "Tahoma", 18, SWT.NORMAL));
lblTwo.setText("Hello World!!!!");
}

}
Previous Topic:Text Widget: How to check (verify) user input?
Next Topic:Extend SWT with AspectJ
Goto Forum:
  


Current Time: Thu Apr 25 13:00:31 GMT 2024

Powered by FUDForum. Page generated in 0.03094 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top