|
@ -13,21 +13,34 @@ import javax.swing.JTextField; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class MyCopy extends JFrame{ |
|
|
public class MyCopy extends JFrame{ |
|
|
|
|
|
|
|
|
public MyCopy(String RutaIn, String RutaOut) throws IOException { |
|
|
|
|
|
|
|
|
private JLabel Porcentaje; |
|
|
|
|
|
private JProgressBar barra; |
|
|
|
|
|
String RutaIn, RutaOut; |
|
|
|
|
|
public MyCopy(String in, String out) throws IOException { |
|
|
|
|
|
RutaIn = in; |
|
|
|
|
|
RutaOut = out; |
|
|
|
|
|
Componentes(); |
|
|
|
|
|
Copiar(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Componentes() { |
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Componentes de Ventana de caarga |
|
|
|
|
|
*/ |
|
|
|
|
|
JLabel Porcentaje = new JLabel(); |
|
|
|
|
|
Porcentaje.setBounds(100,0,20,200); |
|
|
|
|
|
add(Porcentaje); |
|
|
|
|
|
JProgressBar barra = new JProgressBar(); |
|
|
|
|
|
barra.setBounds(100, 20, 150, 10); |
|
|
|
|
|
|
|
|
barra = new JProgressBar(); |
|
|
|
|
|
barra.setBounds(125, 65, 150, 10); |
|
|
add(barra); |
|
|
add(barra); |
|
|
/* |
|
|
|
|
|
* Variables para copiar |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
Porcentaje = new JLabel(); |
|
|
|
|
|
Porcentaje.setBounds(190,-45,100,150); |
|
|
|
|
|
add(Porcentaje); |
|
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
|
|
setSize(400,150); |
|
|
|
|
|
setLocationRelativeTo(null); |
|
|
|
|
|
setLayout(null); |
|
|
|
|
|
setResizable(false); |
|
|
|
|
|
setVisible(true); |
|
|
|
|
|
setTitle("Copiando"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Copiar() throws IOException { |
|
|
File fich = new File(RutaOut); |
|
|
File fich = new File(RutaOut); |
|
|
File fich_a_copiar = new File(RutaIn); |
|
|
File fich_a_copiar = new File(RutaIn); |
|
|
if(fich_a_copiar.exists() == false) { |
|
|
if(fich_a_copiar.exists() == false) { |
|
@ -43,22 +56,17 @@ public class MyCopy extends JFrame{ |
|
|
int c; |
|
|
int c; |
|
|
ArrayList bufferin = new ArrayList(); |
|
|
ArrayList bufferin = new ArrayList(); |
|
|
|
|
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
|
|
setSize(400,100); |
|
|
|
|
|
setLocationRelativeTo(null); |
|
|
|
|
|
setLayout(null); |
|
|
|
|
|
setResizable(false); |
|
|
|
|
|
setVisible(true); |
|
|
|
|
|
setTitle("Copiando"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
while((c = din.read() ) != -1 && bufferin.add(c)) { |
|
|
while((c = din.read() ) != -1 && bufferin.add(c)) { |
|
|
Porcentaje.setText(calculando[cal]); |
|
|
Porcentaje.setText(calculando[cal]); |
|
|
cal++; |
|
|
cal++; |
|
|
if (cal >= 4) |
|
|
if (cal >= 4) |
|
|
cal = 0; |
|
|
cal = 0; |
|
|
Thread.sleep(100); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Thread.sleep(100); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
// TODO Auto-generated catch block |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for(int j = 0; j<bufferin.size(); j++) { |
|
|
for(int j = 0; j<bufferin.size(); j++) { |
|
@ -66,22 +74,16 @@ public class MyCopy extends JFrame{ |
|
|
porcentaje1++; |
|
|
porcentaje1++; |
|
|
Porcentaje.setText(porcentaje1+"%"); |
|
|
Porcentaje.setText(porcentaje1+"%"); |
|
|
barra.setValue(porcentaje1); |
|
|
barra.setValue(porcentaje1); |
|
|
// for(int q = 0; q<=porcentaje1+1; q++) { |
|
|
|
|
|
// System.out.print("@"); |
|
|
|
|
|
// } |
|
|
|
|
|
// for(int q = porcentaje1+1; q<100; q++) { |
|
|
|
|
|
// System.out.print("_"); |
|
|
|
|
|
// } |
|
|
|
|
|
dout.write((int)bufferin.get(j)); |
|
|
dout.write((int)bufferin.get(j)); |
|
|
Thread.sleep(40); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} catch (InterruptedException | IOException e) { |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
Thread.sleep(40); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
// TODO Auto-generated catch block |
|
|
// TODO Auto-generated catch block |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
Porcentaje.setText("Completado!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|