Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-28-2008, 12:28 PM
Member
 
Join Date: Oct 2008
Posts: 8
Rep Power: 0
Sureshgurram is on a distinguished road
Default SWT login form
Hi,

I want code to create a login form in SWT.


The login form should contain user id, password fiels to enter the data, and a login button .

My requirement is that when the user clicks the "enter" key from the keyboard, "login" button action should be done.

Thanks in advance
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-28-2008, 12:55 PM
serjant's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Ukraine,Zaporozhye
Posts: 484
Rep Power: 2
serjant is on a distinguished road
Send a message via ICQ to serjant Send a message via Skype™ to serjant
Default
Everybody wants here something,what have you done so far?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-28-2008, 02:08 PM
Member
 
Join Date: Oct 2008
Posts: 8
Rep Power: 0
Sureshgurram is on a distinguished road
Default
package testing;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;

public class check {
Display display = new Display();
Shell shell = new Shell(display);
Label label1,label2;
Text username;
Text password;
Text text;

public check() {
shell.setLayout(new GridLayout(2, false));
shell.setText("Login form");
label1=new Label(shell, SWT.NULL);
label1.setText("User Name: ");

username = new Text(shell, SWT.SINGLE | SWT.BORDER);
username.setText("");
username.setTextLimit(30);

label2=new Label(shell, SWT.NULL);
label2.setText("Password: ");

password = new Text(shell, SWT.SINGLE | SWT.BORDER);
System.out.println(password.getEchoChar());
password.setEchoChar('*');
password.setTextLimit(30);

Button button=new Button(shell,SWT.PUSH);
button.setText("Submit");
button.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
String selected=username.getText();
String selected1=password.getText();

if(selected==""){
MessageBox messageBox = new MessageBox(shell, SWT.OK |
SWT.ICON_WARNING |SWT.CANCEL);
messageBox.setMessage("Enter the User Name");
messageBox.open();
}
if(selected1==""){
MessageBox messageBox = new MessageBox(shell, SWT.OK |
SWT.ICON_WARNING |SWT.CANCEL);
messageBox.setMessage("Enter the Password");
messageBox.open();
}
else{
MessageBox messageBox=new MessageBox(shell,SWT.OK|SWT.CANCEL);
messageBox.setText("Login Form");
messageBox.setMessage("Welcome:" + username.getText());
messageBox.open();
}
}
});
username.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
password.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

shell.pack();
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new check();
}
}

My requirement is if the user press "enter" key instead of "submit" button after entering the data in text message box should open
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-17-2008, 09:35 AM
Member
 
Join Date: Dec 2008
Location: India->Maharashta->Pune
Posts: 2
Rep Power: 0
shreedharghare is on a distinguished road
Smile Menubar Problem in swt
hi everybody ,
i m shreedhar (new member)
becoz of menu bar my Dialog window is not displaying on ubuntu but it is working finely on xp
if you comment createMenubar method then Dialog is displaying properly on ubutu
my client want menubar in Dialog
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-07-2009, 04:14 PM
Member
 
Join Date: Sep 2009
Posts: 1
Rep Power: 0
Alexandra is on a distinguished road
Post You only need one line of code for...
For having the "login" button as the default button you need just this line:
Code:
shell.setDefaultButton(loginButton);
Greetings
Alexandra.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to close the current form when i open a new form? tpyq NetBeans 6 11-28-2008 07:55 AM
enctype=multipart/form-data with form data in struts vk_satheesh New To Java 0 09-19-2008 01:48 PM
help needed regarding LOGIN form innocent.crook New To Java 2 07-08-2008 05:03 PM
cannot open database requested in login. Login fails banduskank Database 0 06-25-2008 01:41 PM
can i make a login form? mitsakos New To Java 2 12-19-2007 11:14 PM


All times are GMT +2. The time now is 03:08 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org