Answer to Question #51021 in Java | JSP | JSF for Charles Wang

Question #51021
It says "Reached end of file when parsing." How do I fix that? Here is my code.import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class Frame extends JFrame{

private JButton login;
private JTextField user;
private JPasswordField pass;

public Frame(){
super("Login");
setLayout(new FlowLayout());

user = new JTextField(15);
add(user);
pass = new JPasswordField(15);
add(pass);
login = new JButton("Login");
add(login);
login.addActionListener(new ButtonListener());
}

public class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent event) {
if(user.getText().trim().length() == 0 || pass.getText.equals().length() == 0){
JOptionPane.showMessageDialog(null, "Please fill out both of the text-boxes");
1
Expert's answer
2015-03-03T02:12:49-0500
Solution.
You forgot to put 4 braces at the end of the file

javax.swing.JPasswordField;
importjavax.swing.JTextField;
importjavax.swing.JFrame;
importjavax.swing.JButton;
importjava.awt.FlowLayout;
importjava.awt.event.ActionListener;
importjava.awt.event.ActionEvent;


publicclass Frame extends JFrame{

privateJButton login;
privateJTextField user;
privateJPasswordField pass;

publicFrame(){
super("Login");
setLayout(newFlowLayout());

user = newJTextField(15);
add(user);
pass = newJPasswordField(15);
add(pass);
login = newJButton("Login");
add(login);
login.addActionListener(new ButtonListener());
}

public class ButtonListener implements ActionListener{
publicvoid actionPerformed(ActionEvent event) {
if(user.getText().trim().length()== 0 || pass.getText.equals().length() == 0){
JOptionPane.showMessageDialog(null,"Please fill out both of the text-boxes");

}
}
}
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS