vigliom 2 years ago
parent
commit
b161eecd2c
8 changed files with 26 additions and 28 deletions
  1. +0
    -0
      Salida
  2. BIN
      bin/jorpelu/com/MyCopy.class
  3. BIN
      bin/jorpelu/com/Ventana$1.class
  4. BIN
      bin/jorpelu/com/Ventana$2.class
  5. BIN
      bin/jorpelu/com/Ventana.class
  6. +20
    -27
      src/jorpelu/com/MyCopy.java
  7. +6
    -1
      src/jorpelu/com/Ventana.java
  8. +0
    -0
      textop.dat

+ 0
- 0
Salida View File


BIN
bin/jorpelu/com/MyCopy.class View File


BIN
bin/jorpelu/com/Ventana$1.class View File


BIN
bin/jorpelu/com/Ventana$2.class View File


BIN
bin/jorpelu/com/Ventana.class View File


+ 20
- 27
src/jorpelu/com/MyCopy.java View File

@ -10,12 +10,12 @@ import javax.swing.JProgressBar;
public class MyCopy extends JFrame{ public class MyCopy extends JFrame{
private JLabel Porcentaje;
private JLabel porcentaje;
private JProgressBar barra; private JProgressBar barra;
private String RutaIn, RutaOut;
public MyCopy(String in, String out) throws IOException {
RutaIn = in;
RutaOut = out;
private String rutaIn, rutaOut;
public MyCopy(String in, String out) throws IOException, InterruptedException {
rutaIn = in;
rutaOut = out;
Componentes(); Componentes();
Copiar(); Copiar();
@ -25,9 +25,9 @@ public class MyCopy extends JFrame{
barra = new JProgressBar(); barra = new JProgressBar();
barra.setBounds(125, 65, 150, 10); barra.setBounds(125, 65, 150, 10);
add(barra); add(barra);
Porcentaje = new JLabel();
Porcentaje.setBounds(190,-45,100,150);
add(Porcentaje);
porcentaje = new JLabel();
porcentaje.setBounds(190,-45,100,150);
add(porcentaje);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,150); setSize(400,150);
setLocationRelativeTo(null); setLocationRelativeTo(null);
@ -37,9 +37,9 @@ public class MyCopy extends JFrame{
setTitle("Copiando"); setTitle("Copiando");
} }
public void Copiar() throws IOException {
File fich = new File(RutaOut);
File fich_a_copiar = new File(RutaIn);
public void Copiar() throws IOException, InterruptedException {
File fich = new File(rutaOut);
File fich_a_copiar = new File(rutaIn);
if(fich_a_copiar.exists() == false) { if(fich_a_copiar.exists() == false) {
fich_a_copiar.createNewFile(); fich_a_copiar.createNewFile();
} }
@ -49,37 +49,30 @@ public class MyCopy extends JFrame{
DataOutputStream dout = new DataOutputStream(out); DataOutputStream dout = new DataOutputStream(out);
String[] calculando = {"-", "\\", "|", "/"}; String[] calculando = {"-", "\\", "|", "/"};
int cal=0; int cal=0;
int i=0;
int c; int c;
ArrayList bufferin = new ArrayList(); ArrayList bufferin = new ArrayList();
while((c = din.read() ) != -1 && bufferin.add(c)) { while((c = din.read() ) != -1 && bufferin.add(c)) {
Porcentaje.setText(calculando[cal]);
porcentaje.setText(calculando[cal]);
porcentaje.update(porcentaje.getGraphics());
cal++; cal++;
if (cal >= 4) if (cal >= 4)
cal = 0; cal = 0;
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread.sleep(40);
} }
for(int j = 0; j<bufferin.size(); j++) { for(int j = 0; j<bufferin.size(); j++) {
int porcentaje1 = (j*100)/bufferin.size(); int porcentaje1 = (j*100)/bufferin.size();
porcentaje1++; porcentaje1++;
Porcentaje.setText(porcentaje1+"%");
porcentaje.setText("");
porcentaje.setText(porcentaje1+"%");
barra.setValue(porcentaje1); barra.setValue(porcentaje1);
porcentaje.update(porcentaje.getGraphics());
barra.update(barra.getGraphics());
dout.write((int)bufferin.get(j)); dout.write((int)bufferin.get(j));
try {
Thread.sleep(40);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread.sleep(20);
} }
Porcentaje.setText("Completado!");
porcentaje.setText("Completado!");
} }
} }


+ 6
- 1
src/jorpelu/com/Ventana.java View File

@ -35,7 +35,12 @@ public class Ventana extends JFrame {
String r2 = rutaout.getText(); String r2 = rutaout.getText();
try { try {
//Thread?? //Thread??
MyCopy mc = new MyCopy(r1, r2);
try {
MyCopy mc = new MyCopy(r1, r2);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}catch (IOException e1) { }catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }


+ 0
- 0
textop.dat View File


Loading…
Cancel
Save