求助问题出在哪?
package com.ruanko.view;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.JTextComponent;
import com.ruanko.business.FileOperation;
public class JMainFrame extends JFrame{
private JTextField numberTextField=null;
private JTextField nameTextFiel=null;
private JTextField phoneTextField=null;
private JTextField emailTextField=null;
private JTextField addressTextField=null;
private JButton addButton;
public JMainFrame(){
this.setSize(620,500);
this.setTitle("通讯录");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label=new JLabel("欢迎进入通讯录系统");
this.getContentPane().add(label);
this.setLocation(300,200);
this.setLayout(new FlowLayout());
ImageIcon imageIcon=new ImageIcon("image//Contact.png");
Image image=imageIcon.getImage();
this.setIconImage(image);
JPanel mainPanel=new JPanel();
mainPanel.add(new JLabel("联系人路径"));
JTextField pathTextField = new JTextField(43);
String defaultPath="F:/contacts.txt";
pathTextField.setText(defaultPath);
mainPanel.add(pathTextField);
mainPanel.add( new Label("编号:"));
JTextField numberTextField=new JTextField(12);
mainPanel.add(numberTextField);
mainPanel.add( new Label("姓名:"));
JTextField nameTextField=new JTextField(12);
mainPanel.add(nameTextField);
mainPanel.add( new Label("手机号:"));
JTextField phoneTextField=new JTextField(12);
mainPanel.add(phoneTextField);
mainPanel.add( new Label("email:"));
JTextField emailTextField=new JTextField(12);
mainPanel.add(emailTextField);
mainPanel.add( new Label("地址:"));
JTextField addressTextField=new JTextField(30);
mainPanel.add(addressTextField);
mainPanel.add(new JLabel("性别"));
JRadioButton maleButton=null;
JRadioButton femaleButton=null;
maleButton=new JRadioButton("男");
femaleButton=new JRadioButton("女");
mainPanel.add(maleButton);
mainPanel.add(femaleButton);
ButtonGroup buttonGroup=new ButtonGroup();
buttonGroup.add(maleButton);
buttonGroup.add(femaleButton);
maleButton.setSelected(true);
mainPanel.add(new JLabel("关系:"));
JComboBox relationshipBox=null;
String[] relationship={"同事","同学","亲戚","朋友"};
relationshipBox=new JComboBox(relationship);
mainPanel.add(relationshipBox);
addButton=new JButton("新增联系人");
addButton.addActionListener((ActionListener) new AddContactActionListener());
mainPanel.add(addButton);
this.setContentPane(mainPanel);
}
class AddContactActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String number=numberTextField.getText();
JTextComponent nameTextField = null;
String name=nameTextField.getText();
String phone=phoneTextField.getText();
String email=emailTextField.getText();
String address=addressTextField.getText();
String contactInfor=number+"##"+name+"##"+phone+"##"+email+"##"+address;// TODO Auto-generated method stub
String filePath="F:/contacts.txt";
System.out.println(contactInfor);
FileOperation fileoperation=new FileOperation();
fileoperation.saveContact(contactInfor,filePath);
}
public static void main(String[] args){ (为什么这里显示错误,提示去掉static,但是去掉后又不能运行了)
JMainFrame frame=new JMainFrame();
frame.setVisible(true);
}
}
}