www.pudn.com > newminesrc.zip > ListFrame.java


//package mine; 
import javax.swing.JFrame; 
import javax.swing.JOptionPane; 
import java.awt.Dimension; 
import javax.swing.JLabel; 
import java.awt.Rectangle; 
import javax.swing.JButton; 
import javax.swing.BorderFactory; 
import javax.swing.border.EtchedBorder; 
import java.awt.Color; 
import java.awt.Font; 
import java.awt.event.ActionListener; 
import java.awt.event.ActionEvent; 
import java.io.RandomAccessFile; 
 
public class ListFrame extends JFrame  
{ 
  JLabel jLabelPrimer = new JLabel(); 
  JLabel jLabelMiddle = new JLabel(); 
  JLabel jLabelHigh = new JLabel(); 
  JButton jButton1 = new JButton(); 
  JButton jButton2 = new JButton(); 
  RandomAccessFile theAccessFile; 
   
 
  public ListFrame(RandomAccessFile theAccessFile) 
  { 
    this.theAccessFile = theAccessFile; 
    try 
    { 
      jbInit(); 
    } 
    catch(Exception e) 
    { 
      e.printStackTrace(); 
    } 
 
  } 
 
  private void jbInit() throws Exception 
  { 
    this.getContentPane().setLayout(null); 
    this.setSize(new Dimension(291, 152)); 
    this.setTitle("扫雷英雄榜"); 
    jLabelPrimer.setBounds(new Rectangle(20, 10, 250, 25)); 
    jLabelPrimer.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 
    jLabelPrimer.setBackground(new Color(63, 109, 160)); 
    jLabelPrimer.setForeground(new Color(61, 65, 155)); 
    jLabelPrimer.setFont(new Font("华文中宋", 1, 14)); 
    jLabelMiddle.setBounds(new Rectangle(20, 37, 250, 25)); 
    jLabelMiddle.setBackground(new Color(63, 109, 160)); 
    jLabelMiddle.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 
    jLabelMiddle.setForeground(new Color(61, 65, 155)); 
    jLabelMiddle.setFont(new Font("华文中宋", 1, 14)); 
    jLabelHigh.setBounds(new Rectangle(20, 64, 250, 25)); 
    jLabelHigh.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 
    jLabelHigh.setBackground(new Color(63, 109, 160)); 
    jLabelHigh.setForeground(new Color(61, 65, 155)); 
    jLabelHigh.setFont(new Font("华文中宋", 1, 14)); 
    jButton1.setText("重新计分"); 
    jButton1.setBounds(new Rectangle(30, 100, 70, 20)); 
    jButton1.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); 
    jButton1.setForeground(new Color(61, 65, 155)); 
    jButton1.setFont(new Font("华文隶书", 0, 14)); 
    jButton1.addActionListener(new ListFrame_jButton1_actionAdapter(this)); 
    jButton2.setText("确   定"); 
    jButton2.setBounds(new Rectangle(180, 100, 70, 20)); 
    jButton2.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); 
    jButton2.setForeground(new Color(61, 65, 155)); 
    jButton2.setFont(new Font("华文隶书", 0, 14)); 
    jButton2.addActionListener(new ListFrame_jButton2_actionAdapter(this)); 
    this.getContentPane().add(jButton2, null); 
    this.getContentPane().add(jButton1, null); 
    this.getContentPane().add(jLabelHigh, null); 
    this.getContentPane().add(jLabelMiddle, null); 
    this.getContentPane().add(jLabelPrimer, null); 
  } 
 
  void onNewList(ActionEvent e) 
  { 
    try 
    { 
      theAccessFile.seek(0); 
      theAccessFile.readLine(); 
      theAccessFile.readLine(); 
 
      theAccessFile.readLine(); 
      theAccessFile.writeBytes("anonymity           \n"); 
      theAccessFile.writeBytes("9999\n"); 
       
       
      theAccessFile.readLine(); 
      theAccessFile.writeBytes("anonymity           \n"); 
      theAccessFile.writeBytes("9999\n"); 
      theAccessFile.readLine(); 
      theAccessFile.writeBytes("anonymity           \n"); 
      theAccessFile.writeBytes("9999\n"); 
       
       
       
    } 
    catch(Exception ex) 
    { 
      JOptionPane.showMessageDialog(null,"Exception occurred here: " + e); 
    } 
    this.jLabelPrimer.setText("初级        "+ "9999" + "秒        " +"anonymity" ); 
    this.jLabelMiddle.setText("中级        "+ "9999" + "秒        " +"anonymity" ); 
    this.jLabelHigh.setText("高级        "+ "9999" + "秒        " +"anonymity" ); 
    this.repaint(); 
  } 
 
  void onOk(ActionEvent e) 
  { 
    this.dispose(); 
  } 
} 
class ListFrame_jButton1_actionAdapter implements ActionListener  
{ 
  ListFrame adaptee; 
 
  ListFrame_jButton1_actionAdapter(ListFrame adaptee) 
  { 
    this.adaptee = adaptee; 
  } 
 
  public void actionPerformed(ActionEvent e) 
  { 
    adaptee.onNewList(e); 
  } 
} 
class ListFrame_jButton2_actionAdapter implements ActionListener  
{ 
  ListFrame adaptee; 
 
  ListFrame_jButton2_actionAdapter(ListFrame adaptee) 
  { 
    this.adaptee = adaptee; 
  } 
 
  public void actionPerformed(ActionEvent e) 
  { 
    adaptee.onOk(e); 
  } 
}