| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 549 人关注过本帖
标题:运行时,遇到了一个奇怪的问题
只看楼主 加入收藏
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
结帖率:90.24%
收藏
已结贴  问题点数:20 回复次数:3 
运行时,遇到了一个奇怪的问题
package tushu;

import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.util.*;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class Student extends JFrame implements ActionListener {
    private JLabel[] jb ={ new JLabel("学号"), new JLabel("姓名"),
            new JLabel("性别"), new JLabel("班级"),
            new JLabel("借书权限"), new JLabel("院系"),
            new JLabel("密码")
    };
    private JTextField[] jf ={ new JTextField(), new JTextField(),
            new JTextField(), new JTextField(), new JTextField()
    };
    private JPasswordField jpw = new JPasswordField();
    private String[] str ={"是", "否" };
    private JComboBox jcb = new JComboBox(str);
    private JButton[] jbt = { new JButton("添加学生信息"), new JButton("删除学生信息"),
            new JButton("修改学生信息"), new JButton("查询学生信息")
    };
    private Vector<String> v_head = new Vector<String>();
    { v_head.add("学号"); v_head.add("姓名"); v_head.add("性别");
        v_head.add("班级"); v_head.add("院系"); v_head.add("密码");
        v_head.add("借书权限");
    }
    private Vector<Vector> v_data = new Vector<Vector>();
    DefaultTableModel dt  = new DefaultTableModel(v_data, v_head);
    private JTable jt = new JTable(dt);
    private JPanel jp = new JPanel();
    private JScrollPane jsp;
    private JSplitPane jspl = new JSplitPane(JSplitPane.VERTICAL_SPLIT , true);
  
    public Student() {
        this.setLayout(new GridLayout(1,1));
        jp.setLayout(null);
        jb[0].setBounds(20, 10, 50, 30);
        jp.add(jb[0]);
        jf[0].setBounds(100, 10, 150, 30);
        jp.add(jf[0]); jf[0].addActionListener(this);
        jb[1].setBounds(280, 10, 50, 30);
        jp.add(jb[1]);
        jf[1].setBounds(360, 10, 150, 30);
        jp.add(jf[1]); jf[1].addActionListener(this);
        jb[2].setBounds(540, 10, 50, 30);
        jp.add(jb[2]);
        jf[2].setBounds(620, 10, 150, 30);
        jp.add(jf[2]); jf[2].addActionListener(this);
        jb[3].setBounds(800, 10, 100, 30);
        jp.add(jb[3]);
        jcb.setBounds(930, 10, 100, 30);
        jp.add(jcb);
        jcb.addActionListener(this);
        jb[4].setBounds(20, 60, 50, 30);
        jp.add(jb[4]);
        jf[3].setBounds(100, 60, 150, 30);
        jp.add(jf[3]); jf[3].addActionListener(this);
        jb[5].setBounds(280, 60, 50, 30);
        jp.add(jb[5]);
        jf[4].setBounds(360, 60, 150, 30);
        jp.add(jf[4]); jf[4].addActionListener(this);
        jb[6].setBounds(540, 60, 50, 30);
        jp.add(jb[6]);
        jpw.setBounds(620, 60, 150, 30);
        jp.add(jpw); jpw.addActionListener(this);
        for(int i=0; i<jbt.length; i++) {
            jbt[i].setBounds(100+210*i, 80, 200, 30);
            jp.add(jbt[i]);
            jbt[i].addActionListener(this);
        }
        jsp = new JScrollPane(jt);
        jspl.setTopComponent(jp);
        jspl.setBottomComponent(jsp);
        jspl.setDividerLocation(100);
        jspl.setDividerSize(4);
        this.add(jspl);
        this.setBounds(10, 10, 900, 500);
        this.setVisible(true);
    }
   
   
    public void actionPerformed() {
        
    }
   
    public static void main(String[] args) {
        new Student();
    }
}
出现了下面的问题,求解惑!!!
Error occurred during initialization of VM
Could not reserve enough space for object heap
搜索更多相关主题的帖子: private package public import tushu 
2015-10-09 21:33
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:10 
public void actionPerformed() {
        
}
方法非接口抽象方法重写
应改为
public void actionPerformed(ActionEvent evt) {
        
}
形参还需导包
import java.awt.event.ActionEvent;

剑栈风樯各苦辛,别时冰雪到时春
2015-10-09 21:46
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2277
专家分:10647
注 册:2015-3-19
收藏
得分:10 
程序代码:
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

public class Student extends JFrame implements ActionListener {
    private static final long serialVersionUID=1L;
    private JLabel[] jb ={ new JLabel("学号"), new JLabel("姓名"),
            new JLabel("性别"), new JLabel("班级"), 
            new JLabel("借书权限"), new JLabel("院系"),
            new JLabel("密码") 
    };
    private JTextField[] jf ={ new JTextField(), new JTextField(),
            new JTextField(), new JTextField(), new JTextField()
    };
    private JPasswordField jpw = new JPasswordField();
    private String[] str ={"是", "否" };
    private JComboBox<String> jcb = new JComboBox<String>(str);
    private JButton[] jbt = { new JButton("添加学生信息"), new JButton("删除学生信息"),
            new JButton("修改学生信息"), new JButton("查询学生信息")
    };
    private Vector<String> v_head = new Vector<String>();
    { v_head.add("学号"); v_head.add("姓名"); v_head.add("性别");
        v_head.add("班级"); v_head.add("院系"); v_head.add("密码");
        v_head.add("借书权限");
    }
    private Vector<Vector<String>> v_data = new Vector<Vector<String>>();
    DefaultTableModel dt  = new DefaultTableModel(v_data, v_head);
    private JTable jt = new JTable(dt);
    private JPanel jp = new JPanel();
    private JScrollPane jsp;
    private JSplitPane jspl = new JSplitPane(JSplitPane.VERTICAL_SPLIT , true);
  
    public Student() {
        this.setLayout(new GridLayout(1,1));
        jp.setLayout(null);
        jb[0].setBounds(20, 10, 50, 30);
        jp.add(jb[0]);
        jf[0].setBounds(100, 10, 150, 30);
        jp.add(jf[0]); jf[0].addActionListener(this);
        jb[1].setBounds(280, 10, 50, 30);
        jp.add(jb[1]);
        jf[1].setBounds(360, 10, 150, 30);
        jp.add(jf[1]); jf[1].addActionListener(this);
        jb[2].setBounds(540, 10, 50, 30);
        jp.add(jb[2]);
        jf[2].setBounds(620, 10, 150, 30);
        jp.add(jf[2]); jf[2].addActionListener(this);
        jb[3].setBounds(800, 10, 100, 30);
        jp.add(jb[3]);
        jcb.setBounds(930, 10, 100, 30);
        jp.add(jcb);
        jcb.addActionListener(this);
        jb[4].setBounds(20, 60, 50, 30);
        jp.add(jb[4]);
        jf[3].setBounds(100, 60, 150, 30);
        jp.add(jf[3]); jf[3].addActionListener(this);
        jb[5].setBounds(280, 60, 50, 30);
        jp.add(jb[5]);
        jf[4].setBounds(360, 60, 150, 30);
        jp.add(jf[4]); jf[4].addActionListener(this);
        jb[6].setBounds(540, 60, 50, 30);
        jp.add(jb[6]);
        jpw.setBounds(620, 60, 150, 30);
        jp.add(jpw); jpw.addActionListener(this);
        for(int i=0; i<jbt.length; i++) {
            jbt[i].setBounds(100+210*i, 100, 200, 30);
            jp.add(jbt[i]);
            jbt[i].addActionListener(this);
        }
        jsp = new JScrollPane(jt);
        jspl.setTopComponent(jp);
        jspl.setBottomComponent(jsp);
        jspl.setDividerLocation(140);
        jspl.setDividerSize(4);
        this.add(jspl);
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
        this.setVisible(true);
    }
    
    public static void main(String[] args) {
        new Student();
    }
    public void actionPerformed(ActionEvent evt) {
    }
}

剑栈风樯各苦辛,别时冰雪到时春
2015-10-09 21:56
yu1543054075
Rank: 1
等 级:新手上路
帖 子:102
专家分:8
注 册:2015-4-30
收藏
得分:0 
谢谢,知道了
2015-10-10 08:42
快速回复:运行时,遇到了一个奇怪的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017934 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved