错误显示“对于类型XXX,未定义方法XXX” ...我的JFrame有问题吗?

时间:2019-05-18 17:10:22

标签: java swing compiler-errors jframe

长话短说,我想使用自己的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);

  }
}

0 个答案:

没有答案