mainframe.java~3~

来自「这是各类实用工具的源码100例」· JAVA~3~ 代码 · 共 77 行

JAVA~3~
77
字号
package jdatastreamdemo;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;public class MainFrame extends JFrame {  private JPanel contentPane;  private BorderLayout borderLayout1 = new BorderLayout();  private JPanel jPanel1 = new JPanel();  private JScrollPane jScrollPane1 = new JScrollPane();  private JButton jButton1 = new JButton();  private JTextArea jTextArea1 = new JTextArea();  private JLabel jLabel1 = new JLabel();  private JLabel jLabel2 = new JLabel();  private GridLayout gridLayout1 = new GridLayout();  private JTextField jTextField1 = new JTextField();  private JTextField jTextField2 = new JTextField();  File inFile =null;  File outFile =  null;  FileInputStream fis = null;  FileOutputStream fos = null;  DataInputStream dis = null;  DataOutputStream dos = null;  //Construct the frame  public MainFrame() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    //setIconImage(Toolkit.getDefaultToolkit().createImage(MainFrame.class.getResource("[Your Icon]")));    contentPane = (JPanel) this.getContentPane();    contentPane.setLayout(borderLayout1);    this.setSize(new Dimension(395, 195));    this.setTitle("JDataStreamDemo");    jButton1.setText("Start");    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    jLabel1.setMaximumSize(new Dimension(50, 18));    jLabel1.setText("源文件:");    jLabel2.setText("目标文件:");    jPanel1.setLayout(gridLayout1);    gridLayout1.setColumns(2);    gridLayout1.setRows(2);    contentPane.add(jPanel1, BorderLayout.NORTH);    jPanel1.add(jLabel1, null);    jPanel1.add(jTextField1, null);    jPanel1.add(jLabel2, null);    jPanel1.add(jTextField2, null);    contentPane.add(jScrollPane1, BorderLayout.CENTER);    jScrollPane1.getViewport().add(jTextArea1, null);    contentPane.add(jButton1,  BorderLayout.SOUTH);  }  //Overridden so we can exit when window is closed  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void jButton1_actionPerformed(ActionEvent e) {  }}

⌨️ 快捷键说明

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