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

📄 dialog1.java~128~

📁 编程简单
💻 JAVA~128~
字号:
package myproject;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.io.File;
import java.io.IOException;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.DataOutputStream;
import java.io.FileOutputStream;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */
//新建对话框
public class Dialog1 extends JDialog {
  private JPanel panel1 = new JPanel();
  private XYLayout xYLayout1 = new XYLayout();
  private JButton jButton1 = new JButton();
  private JTextField factoryField = new JTextField();
  private JLabel jLabel1 = new JLabel();
  private  ButtonGroup g=new  ButtonGroup() ;
  private JRadioButton jRadioButton1 = new JRadioButton();
  private JRadioButton jRadioButton2 = new JRadioButton();
  private JRadioButton jRadioButton3 = new JRadioButton();
  private JRadioButton jRadioButton4 = new JRadioButton();
  private JButton jButton2 = new JButton();
  private String subFileName =  "审计意见书.dot";
  private Border border1;
  private JLabel jLabel2 = new JLabel();
  private JTextField yearField = new JTextField();
  private JLabel jLabel3 = new JLabel();
  private JTextField manthField = new JTextField();
  private JLabel jLabel4 = new JLabel();
  private JTextField dayField = new JTextField();
  private JLabel jLabel5 = new JLabel();
  private JLabel jLabel6 = new JLabel();
  private JTextField xmField = new JTextField();


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

  public Dialog1() {
    this(null, "新建对话框", false);
  }
  private void jbInit() throws Exception {
    border1 = BorderFactory.createEmptyBorder(0,10,15,10);
    panel1.setLayout(xYLayout1);
    jButton1.setText("确定");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    factoryField.setText("");
    jLabel1.setText("审计单位名:");

    jRadioButton1.setSelected(true);
    jRadioButton1.setText("审计意见书");
    jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jRadioButton1_actionPerformed(e);
      }
    });
    jRadioButton2.setText("审计决定书");
    jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jRadioButton2_actionPerformed(e);
      }
    });
    jRadioButton3.setText("审计工作记录");
    jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jRadioButton3_actionPerformed(e);
      }
    });
    jRadioButton4.setText("审计工作底稿");
    jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jRadioButton4_actionPerformed(e);
      }
    });
    jButton2.setText("取消");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton2_actionPerformed(e);
      }
    });
    panel1.setBorder(border1);
    jLabel2.setText("审计时间:");
    jLabel3.setText("年");
    jLabel4.setText("月");
    jLabel5.setText("日");
    jLabel6.setText("审计项目:");
    g.add(jRadioButton1 );
    g.add(jRadioButton2 );
    g.add(jRadioButton3 );
    g.add(jRadioButton4 );
    panel1.add(factoryField,       new XYConstraints(110, 62, 226, 30));
    panel1.add(yearField,     new XYConstraints(110, 149, 51, 28));
    panel1.add(xmField,       new XYConstraints(109, 105, 227, 30));
    panel1.add(jButton1,  new XYConstraints(125, 202, -1, 28));
    panel1.add(jButton2,  new XYConstraints(201, 202, -1, 28));
    panel1.add(dayField,          new XYConstraints(271, 149, 51, 28));
    panel1.add(jLabel5,  new XYConstraints(323, 149, 24, 28));
    panel1.add(jLabel4,  new XYConstraints(249, 149, 19, 28));
    panel1.add(manthField,    new XYConstraints(195, 149, 51, 28));
    panel1.add(jLabel3,  new XYConstraints(169, 149, 24, 28));
    panel1.add(jLabel6, new XYConstraints(25, 106, 67, 28));
    panel1.add(jLabel2,  new XYConstraints(25, 144, 68, 38));
    panel1.add(jLabel1,     new XYConstraints(11, 66, 74, 22));
    panel1.add(jRadioButton1,  new XYConstraints(9, 27, 89, -1));
    panel1.add(jRadioButton4, new XYConstraints(310, 27, -1, -1));
    panel1.add(jRadioButton3,  new XYConstraints(209, 27, 101, -1));
    panel1.add(jRadioButton2,    new XYConstraints(108, 27, 92, -1));
    this.getContentPane().add(panel1, BorderLayout.CENTER);
  }

  void jRadioButton1_actionPerformed(ActionEvent e) {
    subFileName = "审计意见书.dot";
  }

  void jButton2_actionPerformed(ActionEvent e) {
    this.setVisible(false);
    this.dispose();
  }

  void jRadioButton2_actionPerformed(ActionEvent e) {
    subFileName = "审计决定书.dot";
  }

  void jRadioButton3_actionPerformed(ActionEvent e) {
    subFileName = "审计工作记录.dot";
  }

  void jRadioButton4_actionPerformed(ActionEvent e) {
    subFileName = "审计工作底稿.dot";
  }
//新建按钮事件
  void jButton1_actionPerformed(ActionEvent e) {
    if(factoryField.getText() != null && factoryField.getText().length()> 0&& xmField.getText()!=null&&xmField.getText().length()>0&&
       yearField.getText().length() >= 0&& manthField.getText().length()>= 0&& dayField.getText().length()>=0)//审计单位、审计项目、审计时间非空判断
    {  String dir = factoryField.getText();
      dir = "works/"+factoryField.getText()+xmField.getText()+yearField.getText()+manthField.getText()+dayField.getText();
      try{
        DataInputStream in = new DataInputStream(new FileInputStream("dots/"+subFileName));
        File file = new File("dots/"+subFileName);
        String fileName = file.getName();
        fileName = fileName.substring(0, fileName.length() - 1)+"c";
        System.out.println(file.getAbsolutePath());
        int fileLen = (int)file.length();
        byte[] byteFile = new byte[fileLen];
        in.read(byteFile);
        in.close();
        DataOutputStream out = new DataOutputStream(new FileOutputStream(dir+fileName));
        for(int i = 0; i < byteFile.length; i++){
          out.writeByte(byteFile[i]);
        }
        out.close();
        File newFile = new File(dir+fileName);
        String path = newFile.getAbsolutePath();
        Runtime run = Runtime.getRuntime();
        Process p =  run.exec("D:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.EXE "+path);
        this.setVisible(false);
        this.dispose();
      }
      catch(FileNotFoundException ex){
        System.err.println(ex.toString());
      }
      catch(IOException ex){
        System.err.println(ex.toString());
      }
    }
    else{
      JOptionPane.showMessageDialog(this, "请输入保存文件的文件夹名称!!");
    }
  }


}

⌨️ 快捷键说明

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