loginframe() { Container c = getContentPane(); c.setLayout(null); Color co1 = new Color(252, 251, 251); Color co2 = new Color(153, 153, 153); Color co3 = new Color(0, 0, 0); Font fo1 = new Font("Curlz MT", Font.BOLD, 35); Font fo2 = new Font("Tahoma", Font.BOLD, 14); Font fo3 = new Font("Tahoma", Font.PLAIN, 12); l1 = new JLabel("LOGIN"); l1.setFont(fo1); c.add(l1); l1.setBounds(130, 30, 200, 30); l1.setForeground(co1); l2 = new JLabel("Username"); c.add(l2); l2.setBounds(130, 100, 100, 30); l2.setForeground(co1); l2.setFont(fo2); l3 = new JLabel("Password"); c.add(l3); l3.setBounds(130, 150, 100, 30); l3.setForeground(co1); l3.setFont(fo2); t1 = new JTextField(); t1.setBounds(250, 100, 120, 25); c.add(t1); t1.setBackground(co2); t1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); t1.setForeground(co3); t1.setFont(fo3); p1 = new JPasswordField(); p1.setBounds(250, 150, 120, 25); c.add(p1); p1.setBackground(co2); p1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); b1 = new JButton("Login"); b1.setBounds(140, 220, 70, 30); b1.addActionListener(this); c.add(b1); b2 = new JButton("Exit"); b2.setBounds(270, 220, 70, 30); b2.addActionListener(this); c.add(b2); l4 = new JLabel(""); c.add(l4); l4.setBounds(0, 0, 464, 409); l4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/loginpackage/locked2_1.jpg"))); }
public void actionPerformed(ActionEvent arg0) { Object src = arg0.getSource(); if (src == connectedCheckBox) { if (connectedCheckBox.isSelected()) { passwordField.setEnabled(true); passwordField.setBackground(Color.WHITE); } else { passwordField.setText(""); passwordField.setEnabled(false); passwordField.setBackground(Color.LIGHT_GRAY); } } if (src == okButton) { okPressed = true; PluginServices.getMDIManager().closeWindow(this); return; } if (src == cancelButton) { okPressed = false; PluginServices.getMDIManager().closeWindow(this); return; } if (src == driverComboBox) { String driverName = driverComboBox.getSelectedItem().toString(); IVectorialDatabaseDriver driver; try { driver = (IVectorialDatabaseDriver) LayerFactory.getDM().getDriver(driverName); portTextField.setText("" + driver.getDefaultPort()); } catch (DriverLoadException e1) { portTextField.setText(""); } return; } }
/** Initializes the components composing this display. */ private void initComponents() { admin = false; active = false; groupOwner = false; userPicture = new UserProfileCanvas(); userPicture.setBackground(UIUtilities.BACKGROUND_COLOR); userPicture.setToolTipText("Click to upload your picture."); IconManager icons = IconManager.getInstance(); userPicture.setImage(icons.getImageIcon(IconManager.USER_PHOTO_32).getImage()); loginArea = new JTextField(); boolean a = MetadataViewerAgent.isAdministrator(); loginArea.setEnabled(a); loginArea.setEditable(a); adminBox = new JCheckBox(); adminBox.setVisible(false); adminBox.setBackground(UIUtilities.BACKGROUND_COLOR); ownerBox = new JCheckBox(); ownerBox.setBackground(UIUtilities.BACKGROUND_COLOR); activeBox = new JCheckBox(); activeBox.setBackground(UIUtilities.BACKGROUND_COLOR); activeBox.setVisible(false); passwordButton = new JButton("Change password"); passwordButton.setEnabled(false); passwordButton.setBackground(UIUtilities.BACKGROUND_COLOR); passwordButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changePassword(); } }); manageButton = new JButton("Group"); manageButton.setEnabled(false); manageButton.setBackground(UIUtilities.BACKGROUND_COLOR); manageButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { manageGroup(); } }); passwordNew = new JPasswordField(); passwordNew.setBackground(UIUtilities.BACKGROUND_COLOR); passwordConfirm = new JPasswordField(); passwordConfirm.setBackground(UIUtilities.BACKGROUND_COLOR); oldPassword = new JPasswordField(); oldPassword.setBackground(UIUtilities.BACKGROUND_COLOR); items = new HashMap<String, JTextField>(); ExperimenterData user = (ExperimenterData) model.getRefObject(); GroupData defaultGroup = user.getDefaultGroup(); permissionsPane = new PermissionsPane(defaultGroup.getPermissions(), UIUtilities.BACKGROUND_COLOR); permissionsPane.disablePermissions(); groupLabel = new JLabel(defaultGroup.getName()); groupLabel.setBackground(UIUtilities.BACKGROUND_COLOR); long groupID = defaultGroup.getId(); boolean owner = false; /* if (defaultGroup.getLeaders() != null) owner = setGroupOwner(defaultGroup); else { GroupData g = model.loadGroup(groupID); if (g != null) owner = setGroupOwner(g); } */ Object parentRootObject = model.getParentRootObject(); if (parentRootObject instanceof GroupData) { owner = setGroupOwner((GroupData) parentRootObject); } // Build the array for box. /* Iterator i = userGroups.iterator(); GroupData g; List<GroupData> validGroups = new ArrayList<GroupData>(); while (i.hasNext()) { g = (GroupData) i.next(); if (model.isValidGroup(g)) validGroups.add(g); } groupData = new GroupData[validGroups.size()]; admin = false; active = false; int selectedIndex = 0; int index = 0; i = validGroups.iterator(); boolean owner = false; while (i.hasNext()) { g = (GroupData) i.next(); groupData[index] = g; if (g.getId() == groupID) { if (g.getLeaders() != null) { owner = setGroupOwner(g); originalIndex = index; } } index++; } selectedIndex = originalIndex; groups = EditorUtil.createComboBox(groupData, 0); groups.setEnabled(false); groups.setRenderer(new GroupsRenderer()); if (groupData.length != 0) groups.setSelectedIndex(selectedIndex); */ if (MetadataViewerAgent.isAdministrator()) { // Check that the user is not the one currently logged. oldPassword.setVisible(false); owner = true; adminBox.setVisible(true); activeBox.setVisible(true); adminBox.addChangeListener(this); active = user.isActive(); activeBox.setSelected(active); activeBox.setEnabled(!model.isSelf()); activeBox.addChangeListener(this); // indicate if the user is an administrator.a admin = isUserAdministrator(); adminBox.setSelected(admin); ownerBox.addChangeListener(this); // admin = false; // Now check if the user is the last administrator } else { ownerBox.setEnabled(false); passwordConfirm .getDocument() .addDocumentListener( new DocumentListener() { /** * Allows the user to interact with the password controls depending on the value * entered. * * @see DocumentListener#removeUpdate(DocumentEvent) */ public void removeUpdate(DocumentEvent e) { handlePasswordEntered(); } /** * Allows the user to interact with the password controls depending on the value * entered. * * @see DocumentListener#insertUpdate(DocumentEvent) */ public void insertUpdate(DocumentEvent e) { handlePasswordEntered(); } /** * Required by the {@link DocumentListener} I/F but no-operation implementation in * our case. * * @see DocumentListener#changedUpdate(DocumentEvent) */ public void changedUpdate(DocumentEvent e) {} }); } passwordNew .getDocument() .addDocumentListener( new DocumentListener() { /** * Allows the user to interact with the password controls depending on the value * entered. * * @see DocumentListener#removeUpdate(DocumentEvent) */ public void removeUpdate(DocumentEvent e) { handlePasswordEntered(); } /** * Allows the user to interact with the password controls depending on the value * entered. * * @see DocumentListener#insertUpdate(DocumentEvent) */ public void insertUpdate(DocumentEvent e) { handlePasswordEntered(); } /** * Required by the {@link DocumentListener} I/F but no-operation implementation in our * case. * * @see DocumentListener#changedUpdate(DocumentEvent) */ public void changedUpdate(DocumentEvent e) {} }); ExperimenterData logUser = MetadataViewerAgent.getUserDetails(); if (user.getId() == logUser.getId()) { userPicture.addMouseListener( new MouseAdapter() { /** Brings up a chooser to load the user image. */ public void mouseReleased(MouseEvent e) { uploadPicture(); } }); } }
public void initial() { // J:set up the frame window = new JFrame("UniMeet"); // J:the content panel, using MigLayout("layout constraint", // "column constraint", "row constraint"); JPanel Panel = new JPanel(new MigLayout("", "[315!] 10 [350!]", "10 [] 10")); // J:Divide the content panel into two panels, logPanel and signPanel JPanel LogPanel = new JPanel(new MigLayout("wrap 2, gapy 10", "0 [152!] 1 [152!] 10", "")); JPanel signPanel = new JPanel(new MigLayout("wrap 2, gapy 5", "0 [151!] 3 [151!] 45", "")); /** * Log In Panel * * */ // J:The logo consists of two parts because there are two fonts used // here. Logo = new JLabel("Uni"); Logo2 = new JLabel("Meet"); Logo.setFont(new Font("Serif", Font.ITALIC, 35)); Logo.setForeground(Color.BLUE); Logo2.setFont(new Font("TimesRoman-Bold", Font.ITALIC, 35)); Logo2.setForeground(Color.DARK_GRAY); LogPanel.add(Logo, "align right"); LogPanel.add(Logo2, "align left"); // J:add the slogan below the logo Slogan = new JLabel("To easily find new friends in Universities"); Slogan.setFont(new Font("TimesRoman", Font.ITALIC, 15)); Slogan.setForeground(Color.DARK_GRAY); LogPanel.add(Slogan, "span 2, align 50% 50%"); LogIn = new JLabel("Log In Here"); LogIn.setFont(new Font("Helvetica", Font.PLAIN, 20)); LogIn.setForeground(Color.BLUE); // J:"skip 2" is to skip two components, which is a row. LogPanel.add(LogIn, "span 2, align 50% 50%, skip 2"); // J: instead of having separate JLabel and JTextField, I used // TitleBorder. // J: (applies also to password TextField) emailF = new JTextField(15); Border blueline = BorderFactory.createLineBorder(Color.blue); emailF.setBorder(BorderFactory.createTitledBorder(blueline, "Student Email")); emailF.setBackground(null); LogPanel.add(emailF, "span 2, grow, h 45!, w :270:290"); // **emailF.setDocument(new LimitCharactersInput(30)); passF = new JPasswordField(10); passF.setBorder(BorderFactory.createTitledBorder(blueline, "Password")); passF.setBackground(null); LogPanel.add(passF, "span 2, grow, h 45!, w :270:290"); // **passF.setDocument(new LimitCharactersInput(15)); cantAccess = new JButton("Can't Access your Account?"); cantAccess.setBorderPainted(false); LogPanel.add(cantAccess, "span 2, w :100:, align right, push"); loginButton = new JButton("Log in"); LogPanel.add(loginButton, "skip 1, w :100:, align right, push"); // J:add the login button's function and 'can't access?'button's // function logButtonFunctions(); // J:add LogPanel to the content panel. Panel.add(LogPanel); /** * Sign Up Panel* * */ dateChooser.setVisible(true); // J:add a simple sign up label SignUp = new JLabel("Sign Up Now!"); SignUp.setFont(new Font("Helvetica", Font.PLAIN, 20)); SignUp.setForeground(Color.DARK_GRAY); signPanel.add(SignUp, "span 2, align 50% 50%, aligny baseline"); // J:TextField for first name and last name fName = new JTextField(10); Border Grayline = BorderFactory.createLineBorder(Color.GRAY); fName.setBorder(BorderFactory.createTitledBorder(Grayline, "First Name")); fName.setBackground(Color.WHITE); signPanel.add(fName, "skip 4, span 2, h 40!, grow"); fName.setDocument(new LimitCharactersInput(15)); lName = new JTextField(10); lName.setDocument(new LimitCharactersInput(15)); lName.setBorder(BorderFactory.createTitledBorder(Grayline, "Last Name")); lName.setBackground(Color.WHITE); signPanel.add(lName, "span 2, h 40!, grow"); emailSign = new JTextField(15); emailF.setDocument(new LimitCharactersInput(30)); emailSign.setBorder(BorderFactory.createTitledBorder(Grayline, "Student Email")); emailSign.setBackground(Color.WHITE); signPanel.add(emailSign, "h 40!, grow, span 2"); passwordSign = new JPasswordField(10); passwordSign.setDocument(new LimitCharactersInput(15)); passwordSign.setBorder(BorderFactory.createTitledBorder(Grayline, "Password")); passwordSign.setBackground(Color.WHITE); signPanel.add(passwordSign, "h 40!, grow, span 2"); // J: if we want to add a re-type password Field: // passwordSign2 = new JPasswordField(10); // //***passwordF.setDocument(new LimitCharactersInput(15)); // passwordSign2.setBorder(BorderFactory.createTitledBorder( // Grayline, "Re-type Password")); // passwordSign2.setBackground(Color.WHITE); // signPanel.add(passwordSign2, "h 40!, grow, span 2"); birthday = new JLabel("Birthday"); signPanel.add(birthday, "split 2"); signPanel.add(dateChooser, ""); dateChooser.setDateFormatString("yyyy-MM-dd"); male = new JRadioButton("Male"); female = new JRadioButton("Female"); group = new ButtonGroup(); group.add(male); group.add(female); signPanel.add(male, "split 2"); signPanel.add(female); signupButton = new JButton("Sign Up!"); signPanel.add(signupButton, "skip 7, w :100:, align right"); Panel.add(signPanel); try { signButtonFunctions(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } window.add(Panel); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); window.setSize(685, 400); window.setLocationRelativeTo(null); MigLayout layout = new MigLayout("nogrid"); window.setLayout(layout); }
/** Create the frame. */ public LoginWindow() { setAutoRequestFocus(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 454, 488); contentPane = new JPanel(); contentPane.setForeground(UIManager.getColor("ScrollBar.trackHighlightForeground")); contentPane.setBackground(UIManager.getColor("ScrollBar.track")); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); JTextPane WelcomeMessage = new JTextPane(); WelcomeMessage.setEditable(false); WelcomeMessage.setBackground(UIManager.getColor("Separator.highlight")); WelcomeMessage.setForeground(Color.DARK_GRAY); WelcomeMessage.setFont(new Font("Verdana", Font.BOLD, 11)); WelcomeMessage.setText("\tWelcome to Neighborhood Information Center"); JPanel panel = new JPanel(); panel.setForeground(UIManager.getColor("TextPane.caretForeground")); panel.setBorder(new LineBorder(UIManager.getColor("TextField.background"))); panel.setBackground(UIManager.getColor("TextField.disabledBackground")); JTextPane LoginMessage = new JTextPane(); LoginMessage.setEditable(false); LoginMessage.setText("Please Login to Continue"); LoginMessage.setForeground(SystemColor.controlText); LoginMessage.setFont(new Font("Verdana", Font.BOLD, 11)); LoginMessage.setBackground(UIManager.getColor("TextField.disabledBackground")); LoginField = new JTextField(); LoginField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Login = LoginField.getText(); System.out.println("\n Login-ID is : " + Login); } }); LoginField.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { LoginField.setText(""); LoginField.setForeground(Color.BLACK); } }); LoginField.setBackground(UIManager.getColor("TextField.background")); LoginField.setForeground(SystemColor.scrollbar); LoginField.setText("Login ID"); LoginField.setColumns(10); JButton LoginButton = new JButton("Login"); LoginButton.addActionListener( new ActionListener() { @SuppressWarnings({}) public void actionPerformed(ActionEvent arg0) { Login = LoginField.getText(); System.out.println("\n Login-ID is : " + Login); Password = passwordField.getText(); System.out.println("\n LOGIN BUTTON - Password is : " + Password); // ****************************************************************************** // Set LoginField Back to Normal LoginField.setText(""); LoginField.setBackground(UIManager.getColor("TextField.background")); LoginField.setForeground(SystemColor.scrollbar); LoginField.setText("Login ID"); // Set PasswordField Back to Normal passwordField.setText(""); passwordField.setBackground(UIManager.getColor("TextField.background")); passwordField.setForeground(SystemColor.scrollbar); char c = 0; passwordField.setEchoChar(c); passwordField.setText("Password"); // ******************************************************************************* int Valid = -99; try { int info = 1; Valid = database.getInfo(connection, Login, Password, info); } catch (SQLException e) { // TODO Auto-generated catch block System.out.printf("\n Failed to retrieve \n"); } if (Valid > 0) { System.out.printf(" Successful in Login App. \n"); frame.setVisible(false); userGUI program = new userGUI(); // System.exit(0); } else { UnsuccessfulLogin fail = new UnsuccessfulLogin(Login); fail.NoSuccess(Login); } } }); LoginButton.setBackground(new Color(102, 153, 255)); JTextPane txtpnCreateAnAccount = new JTextPane(); txtpnCreateAnAccount.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { CreateAccount newAcct = new CreateAccount(); newAcct.account(); } }); txtpnCreateAnAccount.setEditable(false); txtpnCreateAnAccount.setText("Create an account"); txtpnCreateAnAccount.setForeground(new Color(25, 25, 112)); txtpnCreateAnAccount.setFont(new Font("Verdana", Font.BOLD, 11)); txtpnCreateAnAccount.setBackground(SystemColor.menu); passwordField = new JPasswordField(); // Setting Password as text passwordField.setBackground(UIManager.getColor("TextField.background")); passwordField.setForeground(SystemColor.scrollbar); passwordField.setText("Password"); char c = 0; passwordField.setEchoChar(c); passwordField.setText("Password"); // Done setting text passwordField.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { char c = 183; passwordField.setForeground(Color.black); passwordField.setEchoChar(c); passwordField.setText(""); } }); passwordField.setBackground(UIManager.getColor("TextField.background")); passwordField.setForeground(SystemColor.scrollbar); passwordField.setText("Password"); passwordField.addActionListener( new ActionListener() { @SuppressWarnings("deprecation") public void actionPerformed(ActionEvent e) { Password = passwordField.getText(); System.out.println("\n Password is : " + Password); } }); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup( gl_panel .createParallelGroup(Alignment.TRAILING) .addGroup( gl_panel .createSequentialGroup() .addContainerGap(60, Short.MAX_VALUE) .addGroup( gl_panel .createParallelGroup(Alignment.TRAILING) .addGroup( gl_panel .createSequentialGroup() .addComponent( txtpnCreateAnAccount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(63)) .addGroup( gl_panel .createSequentialGroup() .addGroup( gl_panel .createParallelGroup(Alignment.TRAILING, false) .addComponent( LoginMessage, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( LoginButton, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( LoginField, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE) .addComponent(passwordField)) .addGap(42))))); gl_panel.setVerticalGroup( gl_panel .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel .createSequentialGroup() .addGap(30) .addComponent( LoginMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(56) .addComponent( LoginField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent( passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(LoginButton) .addPreferredGap(ComponentPlacement.RELATED, 66, Short.MAX_VALUE) .addComponent( txtpnCreateAnAccount, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE) .addGap(47))); panel.setLayout(gl_panel); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup( gl_contentPane .createParallelGroup(Alignment.TRAILING) .addGroup( gl_contentPane .createSequentialGroup() .addContainerGap() .addGroup( gl_contentPane .createParallelGroup(Alignment.LEADING) .addGroup( gl_contentPane .createSequentialGroup() .addComponent( WelcomeMessage, GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE) .addGap(0)) .addGroup( Alignment.TRAILING, gl_contentPane .createSequentialGroup() .addComponent( panel, GroupLayout.PREFERRED_SIZE, 270, GroupLayout.PREFERRED_SIZE) .addGap(66))))); gl_contentPane.setVerticalGroup( gl_contentPane .createParallelGroup(Alignment.LEADING) .addGroup( gl_contentPane .createSequentialGroup() .addContainerGap() .addComponent( WelcomeMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent( panel, GroupLayout.PREFERRED_SIZE, 342, GroupLayout.PREFERRED_SIZE) .addContainerGap(48, Short.MAX_VALUE))); contentPane.setLayout(gl_contentPane); }