Me again...
I read few treads on the subject and tried to make something, but it does not work..
Please, tell me... what have I done wrong?
here is the list of errors:
C:\MyHost\New.java:17: <identifier> expected
btnRegister.addActionListener(new RegisterListener());
^
New.java:19: <identifier> expected
btnClear.addActionListener(new ClearListener());
^
New.java:17: cannot resolve symbol
symbol : class addActionListener
location: package btnRegister
btnRegister.addActionListener(new RegisterListener());
^
New.java:19: cannot resolve symbol
symbol : class addActionListener
location: package btnClear
btnClear.addActionListener(new ClearListener());
^
New.java:158: cannot resolve symbol
symbol : class ActionListener
location: class New.RegisterListener
protected class RegisterListener implements ActionListener
^
New.java:160: cannot resolve symbol
symbol : class ActionEvent
location: class New.RegisterListener
public void actionPerformed(ActionEvent e)
^
New.java:168: cannot resolve symbol
symbol : class ActionListener
location: class New.ClearListener
protected class ClearListener implements ActionListener
^
New.java:170: cannot resolve symbol
symbol : class ActionEvent
location: class New.ClearListener
public void actionPerformed(ActionEvent e)
Here is a code I was trying to compile:
import java.awt.*;
import java.applet.*;
import java.io.*;
import java.lang.*;
import javax.swing.*;
public class New extends Applet
{
TextField txtUserName;
TextField txtLastName;
TextField txtFirstName;
TextField txtEmail;
Button btnRegister = new Button("Register"
btnRegister.addActionListener(new RegisterListener());
Button btnClear = new Button("Clear"
btnClear.addActionListener(new ClearListener());
Label Label1 = new Label();
Label Label2 = new Label();
Label Label3 = new Label();
Label Label4 = new Label();
Label Label5 = new Label();
Label Label6 = new Label();
Label Label7 = new Label();
Label Label8 = new Label();
Label Label9 = new Label();
javax.swing.JPasswordField JPasswordField1 = new javax.swing.JPasswordField();
javax.swing.JPasswordField JPasswordField2 = new javax.swing.JPasswordField();
public void init()
{
resize(310,240);
setLayout(null);
//adding labels and textfields
Label1.setText("User Name"
add(Label1);
Label1.setBounds(65,12,60,20);
txtUserName=new TextField();
add(txtUserName);
txtUserName.setBounds(140,12,85,18);
Label2.setText("Password"
add(Label2);
Label2.setBounds(70,45,50,20);
add(JPasswordField1);
JPasswordField1.setBounds(140,45,85,18);
Label3.setText("Re-enter Password"
add(Label3);
Label3.setBounds(10,78,115,20);
add(JPasswordField2);
JPasswordField2.setBounds(140,78,85,18);
Label4.setText("Last Name"
add(Label4);
Label4.setBounds(65,111,55,20);
txtLastName=new TextField();
add(txtLastName);
txtLastName.setBounds(140,111,120,18);
Label5.setText("First Name"
add(Label5);
Label5.setBounds(65,144,55,20);
txtFirstName=new TextField();
add(txtFirstName);
txtFirstName.setBounds(140,144,120,18);
Label6.setText("E-mail"
add(Label6);
Label6.setBounds(75,177,55,20);
txtEmail=new TextField();
add(txtEmail);
txtEmail.setBounds(140,177,135,18);
add(btnRegister);
btnRegister.setBounds(140,200,65,23);
}
public String getUserName()
{
return txtUserName.getText();
}
public String setUserName(String s)
{
txtUserName.setText(s);
}
public String getFirstName()
{
return txtFirstName.getText();
}
public String getLastName()
{
return txtLastName.getText();
}
public String getEmail()
{
return txtEmail.getText();
}
public String getLevel()
{
return chLevel.getSelectedItem();
}
protected class RegisterListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource == btnRegister)
{
}
}
}
protected class ClearListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String s="";
if(e.getSource == btnClear)
{
setUserName(s);
}
}
}
}
Have a great day!
I read few treads on the subject and tried to make something, but it does not work..
Please, tell me... what have I done wrong?
here is the list of errors:
C:\MyHost\New.java:17: <identifier> expected
btnRegister.addActionListener(new RegisterListener());
^
New.java:19: <identifier> expected
btnClear.addActionListener(new ClearListener());
^
New.java:17: cannot resolve symbol
symbol : class addActionListener
location: package btnRegister
btnRegister.addActionListener(new RegisterListener());
^
New.java:19: cannot resolve symbol
symbol : class addActionListener
location: package btnClear
btnClear.addActionListener(new ClearListener());
^
New.java:158: cannot resolve symbol
symbol : class ActionListener
location: class New.RegisterListener
protected class RegisterListener implements ActionListener
^
New.java:160: cannot resolve symbol
symbol : class ActionEvent
location: class New.RegisterListener
public void actionPerformed(ActionEvent e)
^
New.java:168: cannot resolve symbol
symbol : class ActionListener
location: class New.ClearListener
protected class ClearListener implements ActionListener
^
New.java:170: cannot resolve symbol
symbol : class ActionEvent
location: class New.ClearListener
public void actionPerformed(ActionEvent e)
Here is a code I was trying to compile:
import java.awt.*;
import java.applet.*;
import java.io.*;
import java.lang.*;
import javax.swing.*;
public class New extends Applet
{
TextField txtUserName;
TextField txtLastName;
TextField txtFirstName;
TextField txtEmail;
Button btnRegister = new Button("Register"
btnRegister.addActionListener(new RegisterListener());
Button btnClear = new Button("Clear"
btnClear.addActionListener(new ClearListener());
Label Label1 = new Label();
Label Label2 = new Label();
Label Label3 = new Label();
Label Label4 = new Label();
Label Label5 = new Label();
Label Label6 = new Label();
Label Label7 = new Label();
Label Label8 = new Label();
Label Label9 = new Label();
javax.swing.JPasswordField JPasswordField1 = new javax.swing.JPasswordField();
javax.swing.JPasswordField JPasswordField2 = new javax.swing.JPasswordField();
public void init()
{
resize(310,240);
setLayout(null);
//adding labels and textfields
Label1.setText("User Name"
add(Label1);
Label1.setBounds(65,12,60,20);
txtUserName=new TextField();
add(txtUserName);
txtUserName.setBounds(140,12,85,18);
Label2.setText("Password"
add(Label2);
Label2.setBounds(70,45,50,20);
add(JPasswordField1);
JPasswordField1.setBounds(140,45,85,18);
Label3.setText("Re-enter Password"
add(Label3);
Label3.setBounds(10,78,115,20);
add(JPasswordField2);
JPasswordField2.setBounds(140,78,85,18);
Label4.setText("Last Name"
add(Label4);
Label4.setBounds(65,111,55,20);
txtLastName=new TextField();
add(txtLastName);
txtLastName.setBounds(140,111,120,18);
Label5.setText("First Name"
add(Label5);
Label5.setBounds(65,144,55,20);
txtFirstName=new TextField();
add(txtFirstName);
txtFirstName.setBounds(140,144,120,18);
Label6.setText("E-mail"
add(Label6);
Label6.setBounds(75,177,55,20);
txtEmail=new TextField();
add(txtEmail);
txtEmail.setBounds(140,177,135,18);
add(btnRegister);
btnRegister.setBounds(140,200,65,23);
}
public String getUserName()
{
return txtUserName.getText();
}
public String setUserName(String s)
{
txtUserName.setText(s);
}
public String getFirstName()
{
return txtFirstName.getText();
}
public String getLastName()
{
return txtLastName.getText();
}
public String getEmail()
{
return txtEmail.getText();
}
public String getLevel()
{
return chLevel.getSelectedItem();
}
protected class RegisterListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource == btnRegister)
{
}
}
}
protected class ClearListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String s="";
if(e.getSource == btnClear)
{
setUserName(s);
}
}
}
}
Have a great day!