|
@ -40,6 +40,7 @@ public class MyAplication { |
|
|
private JFrame frame; |
|
|
private JFrame frame; |
|
|
private JTextField textField; |
|
|
private JTextField textField; |
|
|
private JTextField textField_1; |
|
|
private JTextField textField_1; |
|
|
|
|
|
private JProgressBar progressBar; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Launch the application. |
|
|
* Launch the application. |
|
@ -101,10 +102,11 @@ public class MyAplication { |
|
|
textField_1 = new JTextField(); |
|
|
textField_1 = new JTextField(); |
|
|
splitPane.setRightComponent(textField_1); |
|
|
splitPane.setRightComponent(textField_1); |
|
|
|
|
|
|
|
|
JProgressBar progressBar = new JProgressBar(0,100); |
|
|
|
|
|
|
|
|
JProgressBar progressBar = new JProgressBar(0,314); |
|
|
panel.add(progressBar); |
|
|
panel.add(progressBar); |
|
|
textField_1.setColumns(10); |
|
|
textField_1.setColumns(10); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JButton btnNewButton = new JButton("COPY!"); |
|
|
JButton btnNewButton = new JButton("COPY!"); |
|
|
panel.add(btnNewButton); |
|
|
panel.add(btnNewButton); |
|
|
|
|
|
|
|
@ -113,7 +115,8 @@ public class MyAplication { |
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
// TODO Auto-generated method stub |
|
|
// TODO Auto-generated method stub |
|
|
copy(f1.getText(),f2.getText(), progressBar); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
copy(progressBar); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -122,14 +125,17 @@ public class MyAplication { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void copy(String f1, String f2, JProgressBar progressBar) { |
|
|
|
|
|
|
|
|
private void copy(JProgressBar progressBar) { |
|
|
File input=new File(textField.getText()); |
|
|
File input=new File(textField.getText()); |
|
|
File output=new File(textField_1.getText()); |
|
|
File output=new File(textField_1.getText()); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
FileInputStream in = new FileInputStream(textField.getText()); |
|
|
FileInputStream in = new FileInputStream(textField.getText()); |
|
|
FileOutputStream out = new FileOutputStream(textField_1.getText()); |
|
|
FileOutputStream out = new FileOutputStream(textField_1.getText()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*progressBar.setMaximum(in.readAllBytes().length); |
|
|
|
|
|
in.close();*/ |
|
|
|
|
|
|
|
|
int n=0,c,total = progressBar.getMinimum(); |
|
|
int n=0,c,total = progressBar.getMinimum(); |
|
|
|
|
|
|
|
|
System.out.print ("\nCopiando ..."); |
|
|
System.out.print ("\nCopiando ..."); |
|
@ -137,7 +143,8 @@ public class MyAplication { |
|
|
progressBar.setValue(total++); |
|
|
progressBar.setValue(total++); |
|
|
out.write(c); |
|
|
out.write(c); |
|
|
n++; |
|
|
n++; |
|
|
|
|
|
|
|
|
|
|
|
progressBar.update(progressBar.getGraphics()); |
|
|
|
|
|
Thread.sleep(5); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
in.close(); |
|
|
in.close(); |
|
@ -150,6 +157,9 @@ public class MyAplication { |
|
|
} catch (IOException e1) { |
|
|
} catch (IOException e1) { |
|
|
// TODO Auto-generated catch block |
|
|
// TODO Auto-generated catch block |
|
|
e1.printStackTrace(); |
|
|
e1.printStackTrace(); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
// TODO Auto-generated catch block |
|
|
|
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|