YangChoHsin 2015-06-23 01:53 采纳率: 0%
浏览 2056

在public class DynamicArray extends JFrame类里面添加方法报错

public class DynamicArray extends JFrame {

private JPanel contentPane;
private JTextField textField;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                DynamicArray frame = new DynamicArray();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
private ArrayList<String> arraylist = new ArrayList<String>();


public DynamicArray() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JList list = new JList();
    list.setBounds(25, 82, 198, 155);
    contentPane.add(list);

    JLabel label = new JLabel("\u5B66\u751F\u59D3\u540D\uFF1A");
    label.setBounds(25, 20, 65, 30);
    contentPane.add(label);

    textField = new JTextField();
    textField.setBounds(104, 23, 121, 25);
    contentPane.add(textField);
    textField.setColumns(10);

    JButton btnNewButton = new JButton("添加学生");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //执行动作
            textField.requestFocusInWindow();
            textField.selectAll();// 选择文本框文本准备下次输入
            String text = textField.getText();// 获取用户输入姓名
            if (text.isEmpty())// 过滤为输入姓名的情况
                return;
            arraylist.add(text);// 把姓名添加到数组集合中

// replaceModel();// 把数组集合中内容显示到界面列表控件中
}
});
btnNewButton.setBounds(300, 27, 93, 23);
contentPane.add(btnNewButton);

    JButton btnNewButton_1 = new JButton("删除学生");
    btnNewButton_1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //执行动作

        }
    });
    btnNewButton_1.setBounds(300, 94, 93, 23);
    contentPane.add(btnNewButton_1);






    //后续代码

** private void replaceModel()**
这个地方报了三个错误

![图片说明](https://img-ask.csdn.net/upload/201506/23/1435024391_965631.png)<br>        图片说明

}

}

  • 写回答

1条回答

  • JonsonJiao 2015-06-23 05:01
    关注

    把这一行去掉或者前面加上注释符号,不知道你这两个星号是干什么用的。

    ** private void replaceModel()**
    

    如果是块注释,块注释是这样使用的:

     /** private void replaceModel()**/
    
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况