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