I don't have the swt (standard widget toolkit) which normally comes with the eclipse ide. So I cannot help here. I've posted the code so others may.
It seems like you may be missing a few braces as well.
public class Login
{
Display display = new Display ();
final Shell shell = new Shell (display);
final Label welcomeLabel, label1, label2;
final Button button1;
final Text textField1, textField2;
public Login()
{
label1 = new Label(shell, SWT.BOLD);
label1.setText("Investigator ID: ");
label1.setSize(100,20); // (width, height)
label1.setLocation(20,60); // (x,y) co-ordinates
textField1 = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.WRAP);
textField1.setSize(90,20); // (width, height)
textField1.setLocation(120,60); // (x,y) co-ordinates
textField1.setTextLimit(4);
textField1.addListener(SWT.KeyDown, new Listener()
{
public void handleEvent(Event event){}
});
textField1.addListener(SWT.Traverse, new Listener()
{
public void handleEvent(Event event)
{
event.doit = true;
}
});
button1 = new Button(shell, SWT.BUTTON1);
button1.setSize(90,30); // (width, height)
button1.setLocation(220,75); // (x,y) co-ordinates
button1.setText("Login");
button1.addSelectionListener(login);
shell.setSize(340, 340); // (width, height)
shell.setImage(img1);
shell.setText("Login");
shell.open ();
shell.addListener(SWT.Close, new Listener()
{
public void handleEvent(Event event)
{
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(shell, style);
messageBox.setText("Closing");
messageBox.setMessage("Do You Wish to Close the Application?");
//event.doit = messageBox.open() == SWT.YES;
int response = messageBox.open();
switch (response)
{
case SWT.YES:
System.exit(0);
case SWT.NO:
// tried to just go back to login screen
} // end switch
} // end handle event
}); // end addListener
while (!shell.isDisposed ())
{
if (!display.readAndDispatch ()) display.sleep();
}
display.dispose ();
new Shell(); // call another class that opens another shell
} // end constructor
SelectionListener login = new SelectionListener()
{
public void widgetSelected(SelectionEvent arg0)
{
String response1 = textField1.getText();
String response2 = textField2.getText();
if (!response1.equals("") && !response2.equals(""))
{
new Database(response1, response2);
shell.close();
}
else
{
MessageBox messageBox = new MessageBox(shell, SWT.ICON_WARNING);
messageBox.setText("Error");
messageBox.setMessage("You Must Enter Both Investigator ID & Password");
int buttonID = messageBox.open();
}
}
public void widgetDefaultSelected(SelectionEvent arg0)
{}
}; // end SelectionListener() method