JTextField firstName = new JTextField(); JTextField lastName = new JTextField(); JPasswordField password = new JPasswordField(); final JComponent[] inputs = new JComponent[] { new JLabel("First"), firstName, new JLabel("Last"), lastName, new JLabel("Password"), password }; int result = JOptionPane.showConfirmDialog(null, inputs, "My custom dialog", JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { System.out.println("You entered " + firstName.getText() + ", " + lastName.getText() + ", " + password.getText()); } else { System.out.println("User canceled / closed the dialog, result = " + result); }
private void saveSettings() { String serverAddress = txtServer.getText().trim(); MagePreferences.setServerAddress(serverAddress); MagePreferences.setServerPort(Integer.parseInt(txtPort.getText().trim())); MagePreferences.setUserName(serverAddress, txtUserName.getText().trim()); MagePreferences.setPassword(serverAddress, txtPassword.getText().trim()); MageFrame.getPreferences().put(KEY_CONNECT_AUTO_CONNECT, Boolean.toString(chkAutoConnect.isSelected())); }
private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed if (!this.txtPassword.getText().equals(this.txtPasswordConfirmation.getText())) { MageFrame.getInstance().showError("Passwords don't match."); return; } connection = new Connection(); connection.setHost(this.txtServer.getText().trim()); connection.setPort(Integer.valueOf(this.txtPort.getText().trim())); connection.setUsername(this.txtUserName.getText().trim()); connection.setPassword(this.txtPassword.getText().trim()); connection.setEmail(this.txtEmail.getText().trim()); PreferencesDialog.setProxyInformation(connection); task = new ConnectTask(); task.execute(); }//GEN-LAST:event_btnRegisterActionPerformed
private void btnSubmitNewPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitNewPasswordActionPerformed if (this.txtEmail.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter an email address."); return; } if (this.txtAuthToken.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter an auth token."); return; } if (this.txtPassword.getText().isEmpty()) { MageFrame.getInstance().showError("Please enter a new password."); return; } if (!this.txtPassword.getText().equals(this.txtPasswordConfirmation.getText())) { MageFrame.getInstance().showError("Passwords don't match."); return; } connection = new Connection(); connection.setHost(this.txtServer.getText().trim()); connection.setPort(Integer.valueOf(this.txtPort.getText().trim())); PreferencesDialog.setProxyInformation(connection); connection.setEmail(this.txtEmail.getText().trim()); connection.setAuthToken(this.txtAuthToken.getText().trim()); connection.setPassword(this.txtPassword.getText().trim()); resetPasswordTask = new ResetPasswordTask(); resetPasswordTask.execute(); }//GEN-LAST:event_btnSubmitNewPasswordActionPerformed
connection.setPort(Integer.valueOf(this.txtPort.getText().trim())); connection.setUsername(this.txtUserName.getText().trim()); connection.setPassword(this.txtPassword.getText().trim());
String getTPassword() { return passwordField.getText(); }
JPasswordField passwordField = (JPasswordField)event.getSource(); String text = passwordField.getText();
public static String getName() { JPasswordField jpf = new JPasswordField(24); JLabel jl = new JLabel("Enter Your Name: "); Box box = Box.createHorizontalBox(); box.add(jl); box.add(jpf); int x = JOptionPane.showConfirmDialog(null, box, "Name Entry", JOptionPane.OK_CANCEL_OPTION); if (x == JOptionPane.OK_OPTION) { return jpf.getText(); } return null; }
JPasswordField jt=new JPasswordField("I am a password"); System.out.println("The text is "+jt.getText()); System.out.println("The password is "+jt.getPassword());
@Override public String getText() { return getSwingComponent().getText(); }
public String getText() { return Util.removeUTF8BOM(super.getText()); }
JTextField text1;//username JPasswordField p1;//password try{ Class.forName("oracle.jdbc.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:xe", "hr", "hr"); PreparedStatement st=con.prepareStatement("SELECT * from User1 WHERE Username = ? AND Password = ? "); st.setParameter(1, text1.getText()); st.setParameter(2, p1.getText()); ResultSet rs= st.executeQuery(); if(rs.next()) { //Login successfull. } } catch (SQLException s){ System.out.println("SQL statement is not executed!"); } finally{ rs.close(); con.close(); }
public class Test { public static void main(String args[]) { JTextField firstName = new JTextField(); JTextField lastName = new JTextField(); JPasswordField password = new JPasswordField(); final JComponent[] inputs = new JComponent[] { new JLabel("First"), firstName, new JLabel("Last"), lastName, new JLabel("Password"), password }; int i = JOptionPane.showConfirmDialog(null, inputs, "My custom dialog",JOptionPane.PLAIN_MESSAGE); if(i == 0) System.out.println("You entered " + firstName.getText() + ", " + lastName.getText() + ", " + password.getText()); } }
protected void onConnectButtonActionPerformed(java.awt.event.ActionEvent evt) { if (backend.connected) backend.disconnect(); else backend.connect(dbtype, serverText.getText(), portText.getText(), userText.getText(), passwordText.getText()); }
public class PasswordForm { private static String password = "mypass"; public static void main(String[] args){ //Swing operations should happen on the EDT EventQueue.invokeAndWait( new Runnable(){ public void run(){ //whole UI creation final JTextField usernameInput = new JTextField(10); final JPasswordField passwordInput = new JPasswordField(10); //more UI creation JButton loginInput = new JButton("Login"); loginInput.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog(null,"Username is:" + usernameInput.getText() + " Password is:" + passwordInput.getText()); } }); } } //todo catch the exceptions from the invokeAndWait call } }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // Save to server datastore String serverID = StorageHelper.addRippleServer(label,jTextField1.getText(),jTextField2.getText(),jPasswordField1.getText(),jTextField3.getText(),jTextField4.getText()); if (Utility.VerifyStringVal(serverID)) { JOptionPane.showMessageDialog(null, "Ripple server added successflly","Ripple Server Addition",JOptionPane.INFORMATION_MESSAGE); MainPage.loadOtherTabServers(); } else { JOptionPane.showMessageDialog(null, "Error creating bitcoin server", "Datastore error", JOptionPane.ERROR_MESSAGE); } dispose(); }//GEN-LAST:event_jButton1ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // Save to server datastore String serverID = StorageHelper.addBitcoinServer(label,jTextField2.getText(),jTextField1.getText(),jPasswordField1.getText(),jTextField3.getText()); if (Utility.VerifyStringVal(serverID)) { JOptionPane.showMessageDialog(null, "Bitcoin server added successflly","Bitcoin Server Addition",JOptionPane.INFORMATION_MESSAGE); MainPage.loadOtherTabServers(); } else { JOptionPane.showMessageDialog(null, "Error creating bitcoin server", "Datastore error", JOptionPane.ERROR_MESSAGE); } dispose(); }//GEN-LAST:event_jButton1ActionPerformed
final JPasswordField pass = new JPasswordField("Password"); Font passFont = user.getFont(); pass.setFont(passFont.deriveFont(Font.ITALIC)); pass.setForeground(Color.GRAY); pass.setPreferredSize(new Dimension(150, 20)); pass.setEchoChar((char)0); pass.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { pass.setEchoChar('*'); if (pass.getText().equals("Password")) { pass.setText(""); } } public void focusLost(FocusEvent e) { if ("".equalsIgnoreCase(pass.getText().trim())) { pass.setEchoChar((char)0); pass.setText("Password"); } }});
@SuppressWarnings("deprecation") private void prepareLogin() { Object selected = idCombo.getSelectedItem(); if (selected != null && selected instanceof Account) { Account account = (Account) selected; String password = passwordText.getText(); if (password == null || password.isEmpty()) { SwingHelper.showErrorDialog(this, SharedLocale.tr("login.noPasswordError"), SharedLocale.tr("login.noPasswordTitle")); } else { if (rememberPassCheck.isSelected()) { account.setPassword(password); } else { account.setPassword(null); } if (rememberIdCheck.isSelected()) { accounts.add(account); } else { accounts.remove(account); } account.setLastUsed(new Date()); Persistence.commitAndForget(accounts); attemptLogin(account, password); } } else { SwingHelper.showErrorDialog(this, SharedLocale.tr("login.noLoginError"), SharedLocale.tr("login.noLoginTitle")); } }
private void prepareLogin() { Object selected = idCombo.getSelectedItem(); if (selected != null && selected instanceof Account) { Account account = (Account) selected; String password = passwordText.getText(); if (password == null || password.isEmpty()) { SwingHelper.showErrorDialog(this, _("loginDialog.missingPassword"), _("errors.errorTitle")); } else { if (rememberPassCheck.isSelected()) { account.setPassword(password); } else { account.setPassword(null); } if (rememberIdCheck.isSelected()) { accounts.add(account); } else { accounts.remove(account); } account.setLastUsed(new Date()); Persistence.commitAndForget(accounts); attemptLogin(account, password); } } else { SwingHelper.showErrorDialog(this, _("loginDialog.missingId"), _("errors.errorTitle")); } }