下面是一个使用 Java Swing 的简单 Java 表单。它应该创建小程序并显示一个简单的表单,但不会出现表单或任何错误。我不确切知道其中缺少什么。
import java.awt.*;
import javax.swing.*;
public class front extends JApplet implements ActionListener{
// Labels
JLabel lblName = new JLabel();
JLabel lblCountry = new JLabel();
JLabel lblDesc = new JLabel();
// Text Fields
JTextField txtName = new JTextField();
JTextField txtCountry = new JTextField();
JTextField txtDesc = new JTextField();
// Save and cancel buttons
JButton save = new JButton("Save");
JButton cancel = new JButton("Cancel");
// The main window (frame)
JFrame frame = new JFrame("Author Registeration");
JPanel panel = new JPanel();
public void init(){
//frame.add(panel);
panel.setLayout(new FlowLayout());
panel.add(lblName);
panel.add(txtName);
panel.add(lblCountry);
panel.add(txtCountry);
panel.add(lblDesc);
panel.add(txtDesc);
panel.add(cancel);
panel.add(save);
getContentPane().add(panel);
//frame.SetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
}
//@Override
public void actionPerformed(ActionEvent e) {
}
}