eclipse下面实现的java扫雷游戏

源代码在线查看: images.java

软件大小: 254 K
上传用户: makai1630
关键词: eclipse java
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				 * Created on Apr 7, 2005
				 *
				 * TODO load the image to memory when this program is loaded, then program can
				 * use image from memory directly
				 */
				package view;
				
				import java.awt.Image;
				import java.net.URL;
				
				import javax.imageio.ImageIO;
				import javax.swing.ImageIcon;
				
				import mqqqvpppm.JMineSweeper;
				
				/**
				 * @author mqqqvpppm
				 * 
				 * TODO load the image to memory when this program is loaded, then program can
				 * use image from memory directly
				 */
				public class Images {
					/** Returns an ImageIcon, or null if the path was invalid. */
					protected static javax.swing.ImageIcon createImageIcon(String path) {
						java.net.URL imgURL = JMineSweeper.class.getResource(path);
						if (imgURL != null) {
							return new javax.swing.ImageIcon(imgURL);
						} else {
							System.err.println("Couldn't find file: " + path);
							return null;
						}
					}
				
					protected static Image createImage(String path) {
						try {
							URL imgURL = JMineSweeper.class.getResource(path);
							Image ret = ImageIO.read(imgURL);
							return ret;
						} catch (Exception exception) {
							return null;
						}
					}
					
					public static final Image FRAME_IMAGE = createImage("images/mainFrameIcon.gif");
					
					public static final ImageIcon START_BEGIN = createImageIcon("images/START_BEGIN.gif");
					
					public static final ImageIcon START_RUN = createImageIcon("images/START_RUN.gif");
				
					public static final ImageIcon START_END = createImageIcon("images/START_END.gif");
				
					public static final Image[] number = { createImage("images/1.gif"),
							createImage("images/2.gif"), createImage("images/3.gif"),
							createImage("images/4.gif"), createImage("images/5.gif"),
							createImage("images/6.gif"), createImage("images/7.gif"),
							createImage("images/8.gif") };
				
					public static final Image MINE = createImage("images/MINE.gif");
				
					public static final Image MINE_WRONG = createImage("images/MINE_WRONG.gif");
				
					public static final Image MINE_BLAST = createImage("images/MINE_BLAST.gif");
				
					public static final Image CLICKED = createImage("images/CLICKED.gif");
				
					public static final Image UNCLICKED = createImage("images/UNCLICKED.gif");
				
					public static final Image MARKED = createImage("images/MARKED.gif");
				
					public static final Image MARKED_MINE = createImage("images/MARKED_MINE.gif");
				
				
				}			

相关资源