Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » import SWT app in another SWT app as popup
import SWT app in another SWT app as popup [message #441438] Mon, 16 August 2004 09:56
Eclipse UserFriend
Originally posted by: peter.clueless.be

Hello all,

I made a little login window, which I want to use in another, existing
SWT application, as popup.

The code of my login window is as following:

class Login implements SelectionListener {
private Text username;

private Text password;

private Button logon;

public Login(Shell shell) {
Label l1 = new Label(shell, SWT.RIGHT);
l1.setText("Username: ");
username = new Text(shell, SWT.SINGLE);

Label l2 = new Label(shell, SWT.RIGHT);
l2.setText("Password: ");
password = new Text(shell, SWT.SINGLE);
password.setEchoChar('*');

logon = new Button(shell, SWT.PUSH | SWT.CENTER);
logon.setText("Logon");
logon.addSelectionListener(this);
}

public void widgetSelected(SelectionEvent e) {
if (e.getSource() == this.logon) {
String usernameValue = this.username.getText();
String passwordValue = this.password.getText();
System.out.println("Logon user: " + usernameValue
+ " with password: " + passwordValue);
}
}

public void widgetDefaultSelected(SelectionEvent e) {

}
}


The skeleton of my current app is:

class MainWindow {
private Shell m_shell = null;

MainWindow() {
}

public Shell open(Display display) {
m_shell = new Shell(display);
m_shell.setSize(240, 360);

GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
m_shell.setLayout(gridLayout);

...

return m_shell;
}
}

class Main {
public static void main(String args[]) {
Display display = new Display();
MainWindow mainWindow = new MainWindow();

Shell shell = mainWindow.open(display);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();
}
}

How can I 'import' Login, so when the user clicks on a button (for
example), the window is shown as a popup in my current application.

Thanks a lot for your help,

--
Peter
Previous Topic:is it possible to have different DND transfer types for different nodes in a tree?
Next Topic:How the Eclipse Layout is build?
Goto Forum:
  


Current Time: Thu Mar 28 20:13:44 GMT 2024

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

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

Back to the top