PreviewPanel.java~33~
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:3k
源码类别:

Java编程

开发平台:

Java

  1. package russiagame;
  2. /**
  3.  * <p>Title: </p>
  4.  * <p>Description: </p>
  5.  * <p>Copyright: Copyright (c) 2003</p>
  6.  * <p>Company: </p>
  7.  * @author not attributable
  8.  * @version 1.0
  9.  */
  10. import javax.swing.*;
  11. import java.awt.*;
  12. import java.awt.event.*;
  13. public class PreviewPanel
  14.     extends Panel {
  15.   private GameTable gPreviewTable;
  16.   private Image myImage0, myImage1; //加载两个图片,用来覆盖背景和组成方块
  17.   private int intWhich;
  18.   public PreviewPanel(PreviewTable gPreviewTable) {
  19.     intWhich = 0;
  20.     myImage0 = getToolkit().getImage("b0.jpg");
  21.     myImage1 = getToolkit().getImage("b1.jpg");
  22.   }
  23.   public void PreviewGraph(int intWhich)
  24.   {
  25.     this.intWhich = intWhich;
  26.     this.repaint();
  27.   }
  28.   public void paint(Graphics g) { //画下一个提前显示的方块
  29.     for (int i = 0; i < 4; i++) //先全部用白方块覆盖
  30.       for (int j = 0; j < 4; j++)
  31.         g.drawImage(myImage0, 0 + i * (15 + 2), 0 + j * (15 + 2), this);
  32.     System.out.println(intWhich);
  33.     intWhich =1;
  34.     switch (intWhich) { //根据标志决定画哪个方块,画蓝方块
  35.       case 1:g.drawImage(myImage1,17,180,this);
  36.              g.drawImage(myImage1,17,197,this);
  37.              g.drawImage(myImage1,17,214,this);
  38.              g.drawImage(myImage1,17,231,this);
  39.         break;
  40.       case 2:
  41.         g.drawImage(myImage1, 0, 197, this);
  42.         g.drawImage(myImage1, 0, 214, this);
  43.         g.drawImage(myImage1, 17, 197, this);
  44.         g.drawImage(myImage1, 17, 214, this);
  45.         break;
  46.       case 3:
  47.         g.drawImage(myImage1, 0, 197, this);
  48.         g.drawImage(myImage1, 0, 214, this);
  49.         g.drawImage(myImage1, 17, 180, this);
  50.         g.drawImage(myImage1, 17, 197, this);
  51.         break;
  52.       case 4:
  53.         g.drawImage(myImage1, 0, 180, this);
  54.         g.drawImage(myImage1, 0, 197, this);
  55.         g.drawImage(myImage1, 17, 197, this);
  56.         g.drawImage(myImage1, 17, 214, this);
  57.         break;
  58.       case 5:
  59.         g.drawImage(myImage1, 0, 180, this);
  60.         g.drawImage(myImage1, 0, 197, this);
  61.         g.drawImage(myImage1, 0, 214, this);
  62.         g.drawImage(myImage1, 17, 180, this);
  63.         break;
  64.       case 6:
  65.         g.drawImage(myImage1, 0, 180, this);
  66.         g.drawImage(myImage1, 17, 180, this);
  67.         g.drawImage(myImage1, 17, 197, this);
  68.         g.drawImage(myImage1, 17, 214, this);
  69.         break;
  70.       case 7:
  71.         g.drawImage(myImage1, 17, 197, this);
  72.         g.drawImage(myImage1, 17, 214, this);
  73.         g.drawImage(myImage1, 0, 214, this);
  74.         g.drawImage(myImage1, 34, 214, this);
  75.         break;
  76.       case 8:
  77.         g.drawImage(myImage1, 17, 197, this);
  78.         break;
  79.       default:
  80.         break;
  81.     }
  82.   }
  83. }