开发工具:
文件大小: 3kb
下载次数: 0
上传时间: 2008-09-10
详细说明: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; class FrameClass extends Frame // implements ActionListener { MenuBar mb; Menu caozuo,shezhi,bangzhu; MenuItem star,close; TangGraphics p=new TangGraphics(); JButton star1,over; JPanel p1,p2; NextOne p3; Scors p4; Thread tankthread; Random makeobjet; int N,next; boolean isgo=false; Label string; FrameClass() { super("测试俄罗斯方块"); setSize(241,232); setLocation(400,200); setLayout(new BorderLayout(10,10)); make objet=new Random(); N=makeobjet.nextInt(19); setBackground(Color.yellow); mb=new MenuBar(); caozuo=new Menu("操作"); shezhi=new Menu("设置"); bangzhu=new Menu("帮助"); caozuo.add(star=new MenuItem("开始")); caozuo.add(close=new MenuItem("结束")); mb.add(caozuo); mb.add(shezhi); mb.add(bangzhu); setMenuBar(mb); string=new Label("制作人: 连泽荣 "); star1=new JButton("开始"); over=new JButton("结束"); p1=new JPanel(new GridLayout(3,1,10,10)); p2=new JPanel(); p3=new NextOne(N); p4=new Scors("0 point"); p4.setBackground(Color.green); p1.add(p3); p1.add(p4); p1.add(p2); p1.setBackground(Color.yellow); // p2.setLayout(new GridLayout(1,2,10,10)); p2.add(string); // p2.add(star1); // p2.add(over); p3.setBackground(Color.black); p3.setSize(100,60); add(p,"Center"); add(p1,"East"); setResizable(false); // star1.addActionListener(this); // over.addActionListener(this); addWindowListener(new windowlistener()); addKeyListener(new keymonitor()); setVisible(true); // tankthread=new Thread(new listenermonitor()); // tankthread.start(); } public void test() { // System.out.print(" ,x="+p3.getWidth()+" y="+p3.getHeight()); p.draw(next); } public void initp() { p.initmap(); while(!p.gameOver()) { p4.getScors(String.valueOf(p.count)+" ponit"); if(p.box.islive()==false) { next=N; N=makeobjet.nextInt(19); p3.getN(N); test(); } } } public static void main(String argc[]) { (new FrameClass()).initp(); } class windowlistener extends WindowAdapter{ public void windowClosing(WindowEvent e){System.exit(0);} } // private class keymonitor extends KeyAdapter { public void keyPressed(KeyEvent e) { p.keyPressed(e); } } } import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.Graphics; import java.util.*; class NextOne extends JPanel { int BOX[][][]= { { {2,2,2,2}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }, { {2,0,0,0}, {2,0,0,0}, {2,0,0,0}, {2,0,0,0} }, { {3,3,3,0}, {3,0,0,0}, {0,0,0,0}, {0,0,0,0} }, { {3,3,0,0}, {0,3,0,0}, {0,3,0,0}, {0,0,0,0} }, { {0,0,3,0}, {3,3,3,0}, {0,0,0,0}, {0,0,0,0} }, { {3,0,0,0}, {3,0,0,0}, {3,3,0,0}, {0,0,0,0} }, { {4,4,4,0}, {0,0,4,0}, {0,0,0,0}, {0,0,0,0} }, { {0,4,0,0}, {0,4,0,0}, {4,4,0,0}, {0,0,0,0} }, { {4,0,0,0}, {4,4,4,0}, {0,0,0,0}, {0,0,0,0} }, { {4,4,0,0}, {4,0,0,0}, {4,0,0,0}, {0,0,0,0} }, { {5,5,5,0}, {0,5,0,0}, {0,0,0,0}, {0,0,0,0} }, { {0,5,0,0}, {5,5,0,0}, {0,5,0,0}, {0,0,0,0} }, { {0,5,0,0}, {5,5,5,0}, {0,0,0,0}, {0,0,0,0} }, { {5,0,0,0}, {5,5,0,0}, {5,0,0,0}, {0,0,0,0} }, { {6,6,0,0}, {0,6,6,0}, {0,0,0,0}, {0,0,0,0} }, { {0,6,0,0}, {6,6,0,0}, {6,0,0,0}, {0,0,0,0} }, { {0,7,7,0}, {7,7,0,0}, {0,0,0,0}, {0,0,0,0} }, { {7,0,0,0}, {7,7,0,0}, {0,7,0,0}, {0,0,0,0} }, { {8,8,0,0}, {8,8,0,0}, {0,0,0,0}, {0,0,0,0} } }; int N; Thread tankthread; Random makeobjet; public NextOne(int N) { setBorder(BorderFactory.createRaisedBevelBorder()); setBackground(Color.black); this.N=N; tankthread=new Thread(new listenermonitor()); tankthread.start(); } public void getN(int N){ this.N=N; } public void paint(Graphics g) { int i,j; super.paintComponent(g); Color c=g.getColor(); g.setColor(Color.red); for(i=0;i<4;i++) for(j=0;j<4;j++) { if(BOX[N][i][j]!=0) { g.fill3DRect(40+i*10,10+j*10,10,10,true); } } g.setColor(c); } private class listenermonitor implements Runnable { public void run() { while(true) { repaint(); try { Thread.sleep(350); } catch(Exception e){} } } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.