屏幕录象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();
  
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值