Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
2,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. package stocksalesmanager.dialogs;
  2.  
  3. import org.eclipse.swt.SWT;
  4. import org.eclipse.swt.widgets.*;
  5. import org.eclipse.swt.layout.*;
  6.  
  7. public class LoginForm extends Composite
  8. {
  9.     private Text username;
  10.     private Text password;
  11.     private Button loginButton;
  12.    
  13.     public LoginForm(Composite parent, int style)
  14.     {
  15.         super(parent, style);
  16.        
  17.         createGUI();
  18.     }
  19.  
  20.     public String getUsername()
  21.     {
  22.         return username.getText();
  23.     }
  24.    
  25.     public String getPassword()
  26.     {
  27.         return password.getText();
  28.     }
  29.    
  30.     private void createGUI()
  31.     {
  32.         setLayout(new GridLayout(2, false));
  33.        
  34.         // Username
  35.         {
  36.             new Label(this, SWT.NONE).setText("Username:");
  37.             username = new Text(this, SWT.BORDER);
  38.             username.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
  39.                     false));
  40.         }
  41.        
  42.         // Password
  43.         {
  44.             new Label(this, SWT.NONE).setText("Password:");
  45.             password = new Text(this, SWT.PASSWORD | SWT.BORDER);
  46.             password.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
  47.                     false));
  48.         }
  49.        
  50.         // Login button
  51.         {
  52.             GridData gridData = new GridData();
  53.             gridData.horizontalSpan = 2;
  54.             gridData.horizontalAlignment = SWT.END;
  55.             gridData.verticalAlignment = SWT.END;
  56.            
  57.             loginButton = new Button(this, SWT.PUSH);
  58.             loginButton.setText("Login");
  59.             loginButton.setLayoutData(gridData);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement