📄 orderlist.java
字号:
package Game;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class orderList extends JFrame implements Runnable, MouseListener{
/**
*
*/
private static final long serialVersionUID = 1L;
Image offI;
public Image help;
Graphics offG;
int WIDTH;
int HEIGHT;
Container c;
Main m;
orderList(Main m)
{
super();
help=(new ImageIcon("pic/orderList.jpg")).getImage();
this.m=m;
this.setSize(help.getWidth(null),help.getHeight(null));
this.setVisible(true);
this.setResizable(false);
this.setTitle("仙剑排行榜");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
WIDTH=help.getWidth(null);
HEIGHT=help.getHeight(null);
c=this.getContentPane();
offI=c.createImage(c.getWidth(),c.getHeight());
offG=offI.getGraphics();
this.getContentPane().addMouseListener(this);
showPicture();
showOrderList();
update();
new Thread(this).start();
}
private void showOrderList() {
String buffer,strname[]={"","",""},strscore[]={"","",""};
int oldscore[]=new int[3];
int i=0;
String str="";
Font font1=new Font(str, Font.BOLD, 30);
offG.setFont(font1);
offG.setColor(Color.RED);
try {
FileReader infile1;
infile1 = new FileReader("name.txt");
BufferedReader inname=new BufferedReader(infile1);
FileReader infile2=new FileReader("score.txt");
BufferedReader inscore=new BufferedReader(infile2);
str="名次"+" "+"分 数"+" "+"名 字";
offG.drawString(str, 100, 100+i*60);
Font font2=new Font(str, Font.HANGING_BASELINE, 25);
offG.setFont(font2);
offG.setColor(Color.DARK_GRAY);
do
{
buffer=inname.readLine();
if(buffer!=null)
{
strname[i]=buffer;
strscore[i]=inscore.readLine();
str=" "+(i+1)+" "+strscore[i]+" "+strname[i];
offG.drawString(str, 100, 100+(i+1)*60);
}
i++;
}while(buffer!=null);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void showPicture()
{
offG.drawImage(help, 0, 0, null);
update();
}
public void update(){
c.getGraphics().drawImage(offI,0,0,null);
}
public void run() {
while(true)
{
update();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public void mouseClicked(MouseEvent e) {
this.setVisible(false);
m.setEnabled(true);
m.setLocation(100, 200);
m.setVisible(true);
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -