首页>代码>java swing开发GUI射击小游戏一枚>/NewGame/src/com/leng/frame/TheCharts.java
/**
 * 
 */
package com.leng.frame;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.util.List;

import javax.swing.JFrame;

import com.leng.IO.SortBean;
import com.leng.IO.SortDao;
import com.leng.Util.InitImage;
import com.leng.Util.MyMouseListener;

/**
 * 排行榜界面
  @author 冷若寒风逝、此戏已散场、
 * 2013-8-26
 */
public class TheCharts  extends JFrame implements Runnable{
	
/**
 * 媒体追踪器
 */
public	MediaTracker  track;
/**双缓冲画布*/
private Image memoryImage;
/**双缓冲画笔*/
private Graphics memoryGraphics;
/**排行榜操作类**/
SortDao st=new SortDao();
/**接受查询的数据**/
List<SortBean> list;
/**开始绘制分数的 x**/
  private int x=160;
/**开始绘制分数的 y**/
  private int y=50;
	/**
	 * 通关成功的画面
	 * */
	public static Image overImage;
	/**退出按钮的图片**/
	public static Image  tuichu;
	/**排行榜是否运行**/
	public static boolean isStart=true;

	public TheCharts() {
		super("排行榜");
		//设置窗体大小
		this.setSize(900, 700);
		//设置关闭  窗体关闭程序结束
		this.setDefaultCloseOperation(3);
		//窗体居中
		this.setLocationRelativeTo(null); 
		//窗体大小不可以被改变
		this.setResizable(false);
		//设置窗体可见
		this.setVisible(true);
		/**
		 * 双缓冲画布和画笔的初始化
		 */
		/**900*700的内存画布*/
		this.memoryImage=this.createImage(900,700);
		/**内存画笔*/
		this.memoryGraphics=this.memoryImage.getGraphics();
		/**设置画笔颜色*/
		memoryGraphics.setColor(Color.red);
		/**设置字体大小*/
		memoryGraphics.setFont(new Font("宋体",Font.BOLD,25));
		/**
		 * 媒体追踪器
		 */
		 track=new MediaTracker(this);
		 /**添加监听器  在用户点击退出图片的时候返回游戏开始的界面**/
		 this.addMouseListener(new MyMouseListener());
		 /**初始化 游戏结束图片*/
		 InitImage.inOver(track);
		 /**查询排行榜**/
		 list=st.getlist();
		 
	}
	/**绘制游戏失败的画面**/
	private void draw(Graphics g){
		memoryGraphics.drawImage(overImage, 0,0,900,700,null);
		memoryGraphics.drawImage(this.tuichu, 800,640,70,40,null);
		y=130;
		memoryGraphics.drawString("名号"+"           "+"战绩", 190, 120);
		for(int i=0;i<5;i++){
			y+=60;
			memoryGraphics.drawString(i+1+" "+list.get(i).getName(), x, y);
			memoryGraphics.drawString(list.get(i).getPointer()+"", 390, y);
		}
		g.drawImage(this.memoryImage, 0,0,this);
		}
	@Override
	public void run() {
		while(isStart){
			this.draw(this.getGraphics());
		}
		this.dispose();
	}
	public static void main(String[] args) {
		 
	}
}
最近下载更多
wzy5432  LV1 2023年4月18日
huangzy  LV12 2023年4月6日
总有人间一两风  LV8 2022年12月12日
一头土猪  LV7 2021年12月22日
zhanghe001  LV9 2021年12月18日
选了了  LV7 2021年12月13日
my1999  LV2 2021年11月27日
tangjj7260  LV18 2021年11月20日
pipichao  LV6 2021年6月20日
ldx1234  LV4 2021年5月17日
最近浏览更多
dushine  LV3 4月14日
微信网友_7289626841501696  LV3 2024年12月17日
interface  LV22 2024年8月10日
wppppp  LV3 2024年6月4日
bangyiyang  LV2 2023年12月21日
wsgwly  LV6 2023年9月11日
1441854423  LV2 2023年6月30日
1614076596  LV1 2023年5月22日
flygrass  LV12 2023年4月24日
wzy5432  LV1 2023年4月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友