长话短说,我想使用自己的JFrame
进行创建,因为我正在使用SpringLayout
,所以不使用extends JFrame
对我来说要容易得多。
相反,当我尝试调用框架时出现错误
public static void main(String[] args)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DatingMatch
{
JFrame frame = new JFrame("Dating Match");
Container contentPane = frame.getContentPane();
SpringLayout layout = new SpringLayout();
private JMenuBar mainbar = new JMenuBar();
private JMenu menu1 = new JMenu("FILE");
private JMenu menu2 = new JMenu("HELP");
private JMenuItem close = new JMenuItem("CLOSE");
private JMenuItem about = new JMenuItem("ABOUT");
private JMenuItem help = new JMenuItem("HELP");
private JLabel name = new JLabel("NAME :");
private JTextField nameF = new JTextField(40);
private JLabel address = new JLabel ("CITY :");
private JTextField addressF = new JTextField(40);
private JLabel phoneNum = new JLabel("PHONE NO. : ");
private JTextField phoneNumF = new JTextField(40);
private JLabel gender = new JLabel("GENDER");
private String genderS[] = {"MALE","FEMALE"};
private JComboBox genderC = new JComboBox(genderS);
private JButton next = new JButton("NEXT");
public static void main(String[] args)
{
DatingMatch frame = new DatingMatch();
frame.setVisible(true);
}
}