Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package data;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JProgressBar;
- import java.awt.EventQueue;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.io.IOException;
- public class CopyFile {
- private JFrame frame;
- private JProgressBar bar0;
- private JProgressBar bar1;
- private JProgressBar bar2;
- private JProgressBar bar3;
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- CopyFile window = new CopyFile();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- public CopyFile() {
- initialize();
- }
- private void initialize() {
- frame = new JFrame();
- frame.setBounds(250, 250, 450, 300);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- bar0 = new JProgressBar();
- bar0.setBounds(130, 70, 250, 30);
- frame.getContentPane().add(bar0);
- bar1 = new JProgressBar();
- bar1.setBounds(130, 110, 250, 30);
- frame.getContentPane().add(bar1);
- bar2 = new JProgressBar();
- bar2.setBounds(130, 150, 250, 30);
- frame.getContentPane().add(bar2);
- bar3 = new JProgressBar();
- bar3.setBounds(130, 190, 250, 30);
- frame.getContentPane().add(bar3);
- JButton copy = new JButton("Kopiuj");
- copy.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int i;
- String source = "C:/Users/Osa/Desktop/kopiowanie1/";
- String destination = "C:/Users/Osa/Desktop/New/";
- for (i = 0; i != new File(source).list().length; i++) {
- }
- try {
- Files.createDirectory(Paths.get(destination));
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- Runnable[] runners = new Runnable[4];
- Thread[] threads = new Thread[4];
- runners[0] = new MyRun(source + new File(source).list()[0], destination + new File(source).list()[0],
- bar0);
- runners[1] = new MyRun(source + new File(source).list()[1], destination + new File(source).list()[1],
- bar1);
- runners[2] = new MyRun(source + new File(source).list()[2], destination + new File(source).list()[2],
- bar2);
- runners[3] = new MyRun(source + new File(source).list()[3], destination + new File(source).list()[3],
- bar3);
- for (int counter = 0; counter < 4; counter++) {
- threads[counter] = new Thread(runners[counter]);
- }
- for (int counter = 0; counter < new File(source).list().length; counter++) {
- threads[counter].start();
- }
- }
- });
- copy.setBounds(25, 15, 100, 35);
- frame.getContentPane().add(copy);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement