我的这段代码没有显示输出,也没有错误..(它只是显示小程序已启动)。请帮助谢谢你可以在eclipse中运行它..包含整个代码..非常感谢你的帮助
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordA extends JApplet implements ActionListener {
static JLabel passwordLabel = new JLabel("Please enter your password:");
static JTextField input = new JTextField(20);
static JButton enter = new JButton("Submit");
static Font bigFont = new Font("Arial", Font.BOLD, 16);
final static int WIDTH = 465;
final static int HEIGHT = 150;
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setLayout(new FlowLayout());
frame.setSize(WIDTH, HEIGHT);
frame.setLayout(new FlowLayout());
frame.add(passwordLabel);
passwordLabel.setFont(bigFont);
frame.add(input);
frame.add(enter);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
enter.addActionListener(new Action());
}
static class Action implements ActionListener {
public void actionPerformed(ActionEvent e) {
String inputPassword = input.getText();
String passWord = "Rosebud";
if (inputPassword.equals(passWord)) {
JOptionPane.showMessageDialog(null,
" Your password is correct,"
+ "\n You may proceed.",
"Password Correct",
JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(null,
"Sorry, you have entered an incorrect password,"
+ "\n Make sure your CAPS are not locked.",
"Password Incorrect",
JOptionPane.ERROR_MESSAGE);
}
}
}
}