JAVA问题

[复制链接]
查看11 | 回复1 | 2010-6-9 22:52:44 | 显示全部楼层 |阅读模式
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class Test
{
public static void main(String[] args)
{
App ap=new App();
ap.show();
}
}
class App extends JFrame
{
MainPanel mp;
public App()
{
mp=new MainPanel();
this.getContentPane().add(mp);
this.setSize(400,450);
this.setTitle("小游戏");
}
}
class MainPanel extends JPanel
{
ButtonPanel bp=new ButtonPanel();
CtrlPanel rp=new CtrlPanel();
public MainPanel()
{
this.setLayout(new BorderLayout());
rp.btnstart.addActionListener(new StartListener());
this.add(bp,"Center");
this.add(rp,"South");
}
class StartListener implements ActionListener
{

public void actionPerformed(ActionEvent e)
{

if(e.getActionCommand()=="重新开始")

{

bp.ColorInit();

}
}
}
}
class ButtonPanel extends JPanel
{
JButton[][] b=new JButton[5][5];
public ButtonPanel()
{
this.setLayout(new GridLayout(5,5));

for(int i=0;i0)

this.btnChange(b[r-1][c]);
if(r0)

this.btnChange(b[r][c-1]);
if(c<4)

this.btnChange(b[r][c+1]);


}
}
}
class CtrlPanel extends JPanel
{
JButton btnstart;
public CtrlPanel()
{
btnstart=new JButton("重新开始");
this.add(btnstart);
}
}
帮忙 写出类和成员变量谢了 现在没分。。但是很急帮帮忙把

回复

使用道具 举报

千问 | 2010-6-9 22:52:44 | 显示全部楼层
有6个类:Test ;App;MainPanel;ButtonPanel;MyButtonListener;CtrlPanel成员变量:mp;bp;rp;b; r,c;btnstart
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行