Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Record.java
Package: 扫雷(java).rar [view]
Upload User: penghbff
Upload Date: 2007-04-16
Package Size: 32k
Code Size: 3k
Category:
Shot Game
Development Platform:
Java
- import java.io.*;
- import java.util.*;
- import javax.swing.*;
- import java.awt.event.*;
- import java.awt.*;
- public class Record extends JDialog implements ActionListener
- {
- int time=0;
- String grade=null;
- String key=null;
- String message=null;
- Hashtable hashtable=null;
- JTextField textName;
- JLabel label=null;
- JButton 确定,取消;
- public Record(JFrame frame,Hashtable h)
- {
- super(frame,"记录你的成绩");
- this.time=time;
- this.grade=grade;
- hashtable=h;
- setBounds(100,100,240,160);
- setResizable(false);
- setVisible(false);
- setModal(true);
- 确定=new JButton("确定");
- 取消=new JButton("取消");
- textName=new JTextField(8);
- textName.setText("匿名");
- 确定.addActionListener(this);
- 取消.addActionListener(this);
- Container con=getContentPane();
- con.setLayout(new GridLayout(2,1));
- label=new JLabel("您现在是...高手,输入您的大名上榜");
- con.add(label);
- JPanel p=new JPanel();
- p.add(textName);
- p.add(确定);
- p.add(取消);
- con.add(p);
- addWindowListener(new WindowAdapter()
- {
- public void windwoClosing(WindowEvent e)
- {
- setVisible(false);
- dispose();
- }
- }
- );
- }
- public void setGrade(String grade)
- {
- this.grade=grade;
- label.setText("您现在是"+grade+"高手,输入您的大名上榜");
- }
- public void setTime(int time)
- {
- this.time=time;
- }
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource()==确定)
- {
- message=grade+"#"+time+"#"+" "+textName.getText();
- key=grade;
- writeRecord(key,message);
- setVisible(false);
- dispose();
- }
- if(e.getSource()==取消)
- {
- setVisible(false);
- dispose();
- }
- }
- public void writeRecord(String key,String message)
- {
- File f=new File("英雄榜.txt");
- try{
- FileInputStream in=new FileInputStream(f);
- ObjectInputStream object_in=new ObjectInputStream(in);
- hashtable=(Hashtable)object_in.readObject();
- object_in.close();
- in.close();
- String temp=(String)hashtable.get(key);
- StringTokenizer fenxi=new StringTokenizer(temp,"#");
- fenxi.nextToken();
- int n=Integer.parseInt(fenxi.nextToken());
- if(time<n)
- {
- hashtable.put(key,message);
- FileOutputStream out=new FileOutputStream(f);
- ObjectOutputStream object_out=new ObjectOutputStream(out);
- object_out.writeObject(hashtable);
- object_out.close();
- out.close();
- }
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
- }
- }