⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.java~13~

📁 用jBuilder实现的背单词软件
💻 JAVA~13~
字号:
package vocabulary;

import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.util.Vector;
import java.util.Random;
import javax.swing.event.*;
import java.io.*;


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Book extends JDialog {
  JPanel panel1 = new JPanel();
  XYLayout xYLayout1 = new XYLayout();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JComboBox jComboBox1 = new JComboBox();
  JTextField jTextField1 = new JTextField();
  JTextField jTextField2 = new JTextField();
  JTextField jTextField3 = new JTextField();
  JLabel jLabel5 = new JLabel();
  JRadioButton jRadioButton1 = new JRadioButton();
  JRadioButton jRadioButton2 = new JRadioButton();
  JRadioButton jRadioButton3 = new JRadioButton();
  JRadioButton jRadioButton4 = new JRadioButton();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();

  // int iStartPos = 1, iReviewNum = 100, iScanRate = 2000, iOrder = 0, iBookIndex=0;

  public Book(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
      //jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public Book() {
    this(null, "", false);
  }

  private void jbInit() throws Exception {
    panel1.setLayout(xYLayout1);
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel1.setText("请选择书:");
    jLabel2.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel2.setText("开始位置:");
    jLabel3.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel3.setText("复习数量:");
    jLabel4.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel4.setText("浏览速度:");
    jComboBox1.setFont(new java.awt.Font("Dialog", 0, 15));
    //  jComboBox1.addActionListener(new Book_jComboBox1_actionAdapter(this));
    jLabel5.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel5.setText("请选择浏览方式:");
    jRadioButton1.setFont(new java.awt.Font("Dialog", 0, 15));
    jRadioButton1.setText("默认");
    jRadioButton1.addActionListener(new Book_jRadioButton1_actionAdapter(this));
    jRadioButton2.setText("顺序");
    jRadioButton2.setFont(new java.awt.Font("Dialog", 0, 15));
    jRadioButton3.setText("逆序");
    jRadioButton3.setFont(new java.awt.Font("Dialog", 0, 15));
    jRadioButton4.setText("随机 ");
    jRadioButton4.setFont(new java.awt.Font("Dialog", 0, 15));
    jButton1.setFont(new java.awt.Font("Dialog", 0, 15));
    jButton1.setText("确定");
    jButton1.addActionListener(new Book_jButton1_actionAdapter(this));
    jButton2.setFont(new java.awt.Font("Dialog", 0, 15));
    jButton2.setText("取消");
    jTextField1.setText("");
    jTextField2.setText("");
    getContentPane().add(panel1);
    panel1.add(jTextField2, new XYConstraints(115, 147, 101, 27));
    panel1.add(jLabel1, new XYConstraints(5, 36, -1, 27));
    panel1.add(jLabel4, new XYConstraints(11, 209, -1, -1));
    panel1.add(jLabel3, new XYConstraints(8, 150, -1, -1));
    panel1.add(jLabel2, new XYConstraints(7, 95, -1, 21));
    panel1.add(jComboBox1, new XYConstraints(114, 36, 101, -1));
    panel1.add(jTextField1, new XYConstraints(115, 93, 101, 27));
    panel1.add(jTextField3, new XYConstraints(115, 206, 101, 27));
    panel1.add(jRadioButton1, new XYConstraints(291, 76, -1, -1));
    panel1.add(jRadioButton4, new XYConstraints(295, 202, -1, -1));
    panel1.add(jRadioButton3, new XYConstraints(292, 160, -1, -1));
    panel1.add(jRadioButton2, new XYConstraints(292, 118, -1, -1));
    panel1.add(jLabel5, new XYConstraints(263, 41, -1, -1));
    panel1.add(jButton1, new XYConstraints(40, 254, 90, 27));
    panel1.add(jButton2, new XYConstraints(200, 255, 98, 25));
  }

  void jRadioButton1_actionPerformed(ActionEvent e) {

  }
    /*
    jTextField1.setText((new Integer(iStartPos)).toString());
               jTextField2.setText((new Integer(iReviewNum)).toString());
               jTextField3.setText((new Integer(iScanRate)).toString());

               try {
                      FileInputStream fsi = new FileInputStream("book.set");
                      InputStreamReader isr = new InputStreamReader(fsi);
                      BufferedReader br = new BufferedReader(isr);

                      String sLine;
                             int iBookNum,i=0;

                              sLine = br.readLine();
                              iBookNum = (new Integer(sLine)).intValue();
                              //System.out.println(iBookNum);

                              String[] sBookName = new String[iBookNum];

                      while ((sLine = br.readLine())!= null) {
                              sBookName[i] = sLine;
                              jComboBox1.addItem(sBookName[i]);
                              i++;  }

              Vector vBook = new Vector(iBookNum);
              for( i = 0; i<iBookNum; i++)
                  vBook.add(i,sBookName[i]);

             // cmbBook = new JComboBox(vBook);

              //jComboBox1.setSelectedIndex(iBookIndex);

              }catch (FileNotFoundException g) {
                      System.out.println ("error" + g );
              }catch(IOException g) {
                      System.out.println ("error" + g );
              }



  }

  void jButton1_actionPerformed(ActionEvent e) {
    if(tm.isRunning())
                                            tm.stop();
                                    sBook   = (String)( cmbBook.getSelectedItem() );
                                    iBookIndex = cmbBook.getSelectedIndex();
                                    iStartPos = (new Integer(tfStartPos.getText())).intValue();
                                    iReviewNum = (new Integer(tfReviewNum.getText())).intValue();
                                    iScanRate  = (new Integer(tfScanRate.getText())).intValue();

                                    sldPacer.setValue(iScanRate);

                                    bnAuto.setText("开始");
                                    bnForward.setEnabled(false);
                                    bnBackward.setEnabled(false);
                                    count = iReviewNum-1;
                                    numLeftwords.setText((new Integer(iReviewNum)).toString());

                            try {
                                    BufferedReader br = new BufferedReader(new FileReader(sBook));
                                    String sLine;
                                    char[] cArray;
                                           int i,l=0;

                                           while ((sLine = br.readLine())!= null)
                                                   l++;
                                           sWord = new String[l];
                                           sMeaning = new String[l];
                                           br.close();
                                            br = new BufferedReader(new FileReader(sBook));
                                           l=0;
                                    while ((sLine = br.readLine())!= null) {
                                            i = 0;
                                            while( (sLine.charAt(i))!= ' ' && i< sLine.length()) {
                                                    i++; }
                                                    cArray = new char[i];
                                            sLine.getChars(0,i,cArray,0);
                                            sWord[l] = new String(sLine.copyValueOf(cArray));

                                            while( (sLine.charAt(i))==' ' && i< sLine.length()) {
                                                    i++; }
                                            cArray = new char[sLine.length()-i];
                                            sLine.getChars(i,sLine.length(),cArray,0);
                                            sMeaning[l]	= new String(sLine.copyValueOf(cArray));
                                            l++;
                                    }
                                    bklength = l;
                                    br.close();
                            }catch(FileNotFoundException f) {
                                    System.out.println ("error" + f );
                            }catch(IOException f) {
                                    System.out.println ("error" + f );
                            }

                                    if(iReviewNum > bklength)
                                            iReviewNum = bklength;
                                    if (iStartPos > bklength - iReviewNum + 1)
                                            iStartPos = bklength-iReviewNum + 1;

                                    Integer iLeftWords = new Integer(iReviewNum);
                                    numLeftwords.setText(iLeftWords.toString());
                                    count = iReviewNum-1;
                                    String cmd = bgOrder.getSelection().getActionCommand();
                                    dialog.dispose();

                                    if(cmd == "默认")
                                            iOrder = 0;
                                    else if (cmd == "顺序") {
                                            iOrder = 1;
                                            //比较字符串,按顺序存放
                                            String sTemp = new String("");
                                            String sTemp1 = new String("");
                                            int k,i,j;
                                            for (i=0;i<bklength-1;i++)
                                            {
                                                    k=i;
                                                    sTemp = sWord[i];
                                                    for(j=i+1;j<bklength;j++)
                                                            if(sTemp.compareTo(sWord[j]) > 0) {
                                                                    sTemp = sWord[j];
                                                                    k=j; }
                                                    sTemp1 = sWord[i];
                                                    sWord[i] = sWord[k];
                                                    sWord[k] = sTemp1;
                                                    sTemp1 = sMeaning[i];
                                                    sMeaning[i] = sMeaning[k];
                                                    sMeaning[k] = sTemp1;
                                            }
                                            }
                                    else if (cmd == "逆序") {
                                            iOrder = 2;
                                            String   sTemp = new String("");
                                            String   sTemp1 = new String("");
                                            int k,i,j;

                                            for (i = 0;i<iReviewNum + iStartPos-1;i++)
                                            {
                                                    k=i;
                                                    sTemp = ((new StringBuffer(sWord[i])).reverse()).toString();
                                                    for(j=i+1;j<bklength;j++)
                                                    {
                                                            sTemp1 = ((new StringBuffer(sWord[j])).reverse()).toString();
                                                            if(sTemp.compareTo(sTemp1) < 0) {
                                                                    sTemp = sTemp1;
                                                                    k=j;  }
                                                    }
                                                    sTemp1 = sWord[i];
                                                    sWord[i] = sWord[k];
                                                    sWord[k] = sTemp1;
                                                    sTemp1 = sMeaning[i];
                                                    sMeaning[i] = sMeaning[k];
                                                    sMeaning[k] = sTemp1;
                                            }
                                    }
                                    else  {
                                            iOrder = 3;
                                            Random rdIndex = new Random();
                                            int[] iIndex = new int [bklength];
                                            int i;
                                            String[] sSwap1 = new String[bklength];
                                            String[] sSwap2 = new String[bklength];
                                            for (i = 0; i<bklength; i++)  {
                                                    iIndex[i] = rdIndex.nextInt(bklength);
                                                    sSwap1[i] = sWord[iIndex[i]];
                                                    sSwap2[i] = sMeaning[iIndex[i]];
                                            }

                                            for( i = 0;i<bklength;i++)  {
                                                    sWord[i] = sSwap1[i];
                                                    sMeaning[i] = sSwap2[i]; }
                                    }

  }*/
}

class Book_jRadioButton1_actionAdapter implements java.awt.event.ActionListener {
  Book adaptee;

  Book_jRadioButton1_actionAdapter(Book adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jRadioButton1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -