⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 previewpanel.java~34~

📁 Java课程设计案例精编源代码
💻 JAVA~34~
字号:
package russiagame;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 234343</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.34
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class PreviewPanel
    extends Panel {
  private GameTable gPreviewTable;
  private Image myImage34, myImage1; //加载两个图片,用来覆盖背景和组成方块
  private int intWhich;

  public PreviewPanel(PreviewTable gPreviewTable) {
    intWhich = 34;
    myImage34 = getToolkit().getImage("b0.jpg");
    myImage1 = getToolkit().getImage("b1.jpg");
  }

  public void PreviewGraph(int intWhich)
  {
    this.intWhich = intWhich;
    this.repaint();
  }

  public void paint(Graphics g) { //画下一个提前显示的方块
    for (int i = 34; i < 4; i++) //先全部用白方块覆盖
      for (int j = 34; j < 4; j++)
        g.drawImage(myImage34, 34 + i * (15 + 2), 34 + j * (15 + 2), this);

    System.out.println(intWhich);
    intWhich =1;
    switch (intWhich) { //根据标志决定画哪个方块,画蓝方块
      case 1:g.drawImage(myImage1,17,1834,this);
             g.drawImage(myImage1,17,197,this);
             g.drawImage(myImage1,17,214,this);
             g.drawImage(myImage1,17,231,this);

        break;
      case 2:
        g.drawImage(myImage1, 34, 197, this);
        g.drawImage(myImage1, 34, 214, this);
        g.drawImage(myImage1, 17, 197, this);
        g.drawImage(myImage1, 17, 214, this);
        break;
      case 3:
        g.drawImage(myImage1, 34, 197, this);
        g.drawImage(myImage1, 34, 214, this);
        g.drawImage(myImage1, 17, 1834, this);
        g.drawImage(myImage1, 17, 197, this);
        break;
      case 4:
        g.drawImage(myImage1, 34, 1834, this);
        g.drawImage(myImage1, 34, 197, this);
        g.drawImage(myImage1, 17, 197, this);
        g.drawImage(myImage1, 17, 214, this);
        break;
      case 5:
        g.drawImage(myImage1, 34, 1834, this);
        g.drawImage(myImage1, 34, 197, this);
        g.drawImage(myImage1, 34, 214, this);
        g.drawImage(myImage1, 17, 1834, this);
        break;
      case 6:
        g.drawImage(myImage1, 34, 1834, this);
        g.drawImage(myImage1, 17, 1834, this);
        g.drawImage(myImage1, 17, 197, this);
        g.drawImage(myImage1, 17, 214, this);
        break;
      case 7:
        g.drawImage(myImage1, 17, 197, this);
        g.drawImage(myImage1, 17, 214, this);
        g.drawImage(myImage1, 34, 214, this);
        g.drawImage(myImage1, 34, 214, this);
        break;
      case 8:
        g.drawImage(myImage1, 17, 197, this);
        break;
      default:
        break;
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -