下面是有关的代码:classEditextendsJFrameimplementsActionListener{privatestaticfinallongserialVersionUID=1L;JButtonadd=newJButton("添加");JButtonremove=newJButton("删除");...
下面是有关的代码:
class Edit extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
JButton add = new JButton("添加");
JButton remove = new JButton("删除");
int i = 2;
Item[] a = new Item[20];
public Edit() {
this.setSize(200, 330);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = this.getPreferredSize();
this.setLocation(screenSize.width / 2 - frameSize.width,
screenSize.height / 2 - frameSize.height);
Container container = getContentPane();
container.setLayout(new GridLayout(0, 1));
a[0] = new Item();
container.add(a[0]);
container.add(add);
container.add(remove);
add.addActionListener(this);
remove.addActionListener(this);
}
这个程序一开始只会显示出右图,点击编辑显示左图,左图的代码如上,但是由于百度知道的字数限制不能把代码都贴上,我开通了一个博客,把代码贴上了,希望各位大神帮忙看看。
http://tansuoxingchen.blog.163.com/blog/static/242216081201410148629564/
展开