屏幕錄象java版軟件,小心共享下.一時興起寫的哦.__界面:luxiang.java

屏幕錄象java版軟件,小心共享下.一時興起寫的哦.__界面:luxiang.java

首先聲明:此測試項目需要lib包在http://zhuseahui.download.csdn.net/下載.0資源分下載.支持共享!同時源文件也在這上面共享了

//界面
package com.show;

import java.awt.*;
import java.awt.event.ActionEvent;

import javax.swing.*;

import com.zip.DeleteFile;
import com.zip.TestZip;
import com.zip.WnetWScreenRecordPlayer;
import com.zip.WnetWScreenRecorder;
import com.zip.ZipFetcher;

public class Luxiang extends JFrame{
/* 北部的組件 */
JLabel jl1,jl2;

/* 南部的組件 */
JButton jb1,jb2,jb3,jb4,jb5;

/* 中部的組件*/
JPanel jp1,jp2;//代表2個選項卡
private static JTextField jtf1;

int zhuangtai=0;
public Luxiang()
{
   //2 創建組件
   /*北部*/
   jl1 = new JLabel("歡迎使用java版的屏幕錄象軟件,有待改進__子寒");
   /*南部*/
   jb1 = new JButton("開始");
   jb2 = new JButton("暫停");
   jb3= new JButton("停止");
   jb4=new JButton("播放錄象");
   jb5=new JButton("選擇");
  
  
   //添加監聽器
   jb1.addActionListener(new java.awt.event.ActionListener(){

    public void actionPerformed(ActionEvent e) {
     // TODO 自動生成方法存根
     System.out.println(jtf1.getText());
     new WnetWScreenRecorder(jtf1.getText(),true).start();
    }
   
   });
  
   jb2.addActionListener(new java.awt.event.ActionListener(){

    public void actionPerformed(ActionEvent e) {
     // TODO 自動生成方法存根
     System.out.println(zhuangtai);
     if(zhuangtai==0)
     {
      zhuangtai=1;
      try {
       new WnetWScreenRecorder(jtf1.getText(),false).wait();
      } catch (InterruptedException e1) {
       // TODO 自動生成 catch 塊
       e1.printStackTrace();
      }
     }
     else
     {
      zhuangtai=0;
      new WnetWScreenRecorder(jtf1.getText(),true).notifyAll();
     }
    }
   
   });
  
   jb3.addActionListener(new java.awt.event.ActionListener(){

    public void actionPerformed(ActionEvent e) {
     // TODO 自動生成方法存根
     System.out.println("stop......");
     new WnetWScreenRecorder(jtf1.getText(),false).stop();
     new TestZip().zipFiles(jtf1.getText()+".zip",jtf1.getText());
     new DeleteFile().delFolder(jtf1.getText());
    }
   
   });
  
   jb4.addActionListener(new java.awt.event.ActionListener(){

    public void actionPerformed(ActionEvent e) {
     // TODO 自動生成方法存根
     jCutter2();
     try {
      new ZipFetcher().unzip(jtf1.getText(),
        jtf1.getText().substring(0,jtf1.getText().lastIndexOf(".")));
     } catch (Exception e1) {
      // TODO 自動生成 catch 塊
      e1.printStackTrace();
     }
     new WnetWScreenRecordPlayer(jtf1.getText().substring(0,
       jtf1.getText().lastIndexOf(".")));
     System.out.println("s========"+jtf1.getText().substring(0,
       jtf1.getText().lastIndexOf(".")));
//     new DeleteFile().delFolder(jtf1.getText().substring(0,
//       jtf1.getText().lastIndexOf(".")));
    }
   
   });
  
  
   jb5.addActionListener(new java.awt.event.ActionListener(){

    public void actionPerformed(ActionEvent e) {
     // TODO 自動生成方法存根
     jCutter();
    }
   
   });
  
   /*中間*/
   jl2 = new JLabel("選擇路徑:");
  
   jtf1 = new JTextField(20);
   jtf1.setText((System.getProperty("user.dir").replace("//", "/")+"/temp").replace("//", "/"));
  
   jp1 = new JPanel();
   jp2 = new JPanel();
  
   //調整按鈕的大小
   jb1.setPreferredSize(new Dimension(66,20));
   //3 設置佈局
   jp1.setLayout(new GridLayout(1,4));
   jp1.add(jb1);
   jp1.add(jb2);
   jp1.add(jb3);
   jp1.add(jb4);
  
   jp2.setLayout(new FlowLayout());
   jp2.add(jl2);
   jp2.add(jtf1);
   jp2.add(jb5);
  
  
   this.add(jl1,BorderLayout.NORTH);
   this.add(jp2,BorderLayout.CENTER);
   this.add(jp1,BorderLayout.SOUTH);
  
   //5 展現
   this.setTitle("歡迎使用java版的屏幕錄象軟件,有待改進__子寒");
   this.setResizable(false);
   this.setSize(600,140);
   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   this.setVisible(true);
  
}

private static void jCutter() {
   // TODO 自動生成方法存根
   String filePath="";
   JFileChooser chooser=new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int result=chooser.showOpenDialog(null);
        String fname=chooser.getName(chooser.getSelectedFile());
        System.out.println("fname--->"+fname);
        if(result==JFileChooser.APPROVE_OPTION)
        {
           
        filePath=chooser.getSelectedFile().getPath();
             System.out.println("filePath1--->"+filePath);
             ShowJTextFieldjtf1(filePath);
        }
}

private static void jCutter2() {
   // TODO 自動生成方法存根
   String filePath="";
   JFileChooser chooser=new JFileChooser();
//        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int result=chooser.showOpenDialog(null);
        String fname=chooser.getName(chooser.getSelectedFile());
        System.out.println("fname--->"+fname);
        if(result==JFileChooser.APPROVE_OPTION)
        {
           
        filePath=chooser.getSelectedFile().getPath();
             System.out.println("filePath1--->"+filePath);
             ShowJTextFieldjtf1(filePath);
        }
        Object[] options = { "確定", "取消" };
        int results= JOptionPane.showOptionDialog(null, "確定播放?", "提示",
        JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,null, options, options[0]);
        if(results==JOptionPane.OK_OPTION)
        {
//            doSave();
        ShowJTextFieldjtf1(filePath);
        System.out.println("sava....");
        }
        if(results==JOptionPane.NO_OPTION )
        {
        jCutter();
        System.out.println("return ....");
        }
}

static void ShowJTextFieldjtf1(String filePath){
   jtf1.setText(filePath.replace("//", "/"));
}



public static void main(String agrs[]){
  
   new Luxiang();
  
}
}

發佈了139 篇原創文章 · 獲贊 5 · 訪問量 34萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章