Re: JTextField and JPasswordField question



I realized i sent it to individual not to the group. In response to the
question that i was asked.


JPasswordField passwordField;
JTextField UsernameField;
int j = 0;

I'll fix the variable name in a moment. so If i do the if statement..
that shoudl fix the problem am I correct?

previously i had this
public void actionPerformed(ActionEvent e)
{
// JTextField inputs = (JTextField)e.getSource();
JPasswordField input = (JPasswordField)e.getSource();
char []password= input.getPassword();
char []name= UsernameField.getPassword();
...............}



"hiwa" <cardinal_ring@xxxxxxxxxxx> wrote in message
news:1180405304.121766.266580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On May 29, 10:28 am, "Jeremy" <jltuc...@xxxxxxxxxxx> wrote:
I hope all is well with you guys Here's my question:
If I have this set up as :
JLabel label1 = new JLabel(" Enter Username: ");
UsernameField = new JTextField(10);
JLabel label2 = new JLabel("Enter the password: ");
passwordField = new JPasswordField(10);

then how come I have error pointing to my usernameField = new
JTextField(10); (incompaitble type) I suspect that the action event
is
misfiring somewhat... do I have to create two different function for text
or
something like that?
public void actionPerformed(ActionEvent e)
{
JTextField inputs = (JTextField)e.getSource();
JPasswordField input = (JPasswordField)e.getSource();
char []password= input.getPassword();
char []name= UsernameField.getPassword();
.................................

What is the declaration of your UsernameField variable? usernameField
is a better name, though.[

For actionPerformed() method, do like this:
if (e.getSource() == userNamefield){
...
}
else if (e.getSource() == passwordField){
...
}




.



Relevant Pages

  • JTextField and JPasswordField question
    ... UsernameField = new JTextField; ... passwordField = new JPasswordField; ... JTextField inputs = e.getSource; ... JPasswordField input = e.getSource; ...
    (comp.lang.java.help)
  • Re: JTextField and JPasswordField question
    ... UsernameField = new JTextField; ... passwordField = new JPasswordField; ... I suspect that the action event is ... JTextField inputs = e.getSource; ...
    (comp.lang.java.help)
  • Re: JTextField and JPasswordField question
    ... passwordField = new JPasswordField; ... then how come I have error pointing to my usernameField = new JTextField; I suspect that the action event is misfiring somewhat... ... JTextField inputs = e.getSource; ...
    (comp.lang.java.help)