jpasswordfield

getText() vs getPassword()

狂风中的少年 提交于 2019-11-27 14:32:27
I'm currently designing a login system for a make-believe company, right now all I have is the Main login, which needs a lot of cleaning up. Below is my login handler. private class LoginButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { if(_uid.getText().equalsIgnoreCase("Nathan") && _pwd.getText().equals("password")) { JOptionPane.showMessageDialog(null, "Congratulations on logging in!"); } else { JOptionPane.showMessageDialog(null, "Error on login!"); } } } As is, this works perfectly fine, but when I change it to _pwd.getPassword.equals("password") it

Moving JPasswordField to absolute position

守給你的承諾、 提交于 2019-11-26 23:43:55
问题 I have this code: import java.awt.Color; import java.awt.Component; import java.awt.Dialog.ModalityType; import java.awt.Dimension; import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.*; public class DialogExample extends JPanel {

Why getText() in JPasswordField was deprecated?

天涯浪子 提交于 2019-11-26 22:48:12
I never thought before, only I used the method getPassword that returning an array of characters and I had seen the getText method was deprecated . But now that I think, why this method was deprecated ?. The Java documentation explains: Deprecated . As of Java 2 platform v1.2, replaced by getPassword . Fetches a portion of the text represented by the component. Returns an empty string if length is 0. For security reasons, this method is deprecated. Use the getPassword method instead. But what are those security reasons ? Any ideas about this? Thank you in advance. When calling getText you get

validate a table's cell using editors

别来无恙 提交于 2019-11-26 21:42:22
问题 I have a Password field editor for my JTable. I want to display an error message if the text length is less than 8 bit when the user clicks to edit another field. I have tried focus listeners. But its not working. Please help me because i have just started workin with java swing. class PasswordEditor extends DefaultCellEditor { TextBox m_passWord = new TextBox(); public PasswordEditor() { super(new TextBox()); } @Override public Object getCellEditorValue() { return this.m_passWord.getText();

getText() vs getPassword()

久未见 提交于 2019-11-26 16:47:51
问题 I'm currently designing a login system for a make-believe company, right now all I have is the Main login, which needs a lot of cleaning up. Below is my login handler. private class LoginButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { if(_uid.getText().equalsIgnoreCase("Nathan") && _pwd.getText().equals("password")) { JOptionPane.showMessageDialog(null, "Congratulations on logging in!"); } else { JOptionPane.showMessageDialog(null, "Error on login!"); }

Why getText() in JPasswordField was deprecated?

给你一囗甜甜゛ 提交于 2019-11-26 08:27:06
问题 I never thought before, only I used the method getPassword that returning an array of characters and I had seen the getText method was deprecated . But now that I think, why this method was deprecated ?. The Java documentation explains: Deprecated . As of Java 2 platform v1.2, replaced by getPassword . Fetches a portion of the text represented by the component. Returns an empty string if length is 0. For security reasons, this method is deprecated. Use the getPassword method instead. But what