Java - Jfilechooser JavaFx

 
Vista:

Jfilechooser JavaFx

Publicado por Nicolay (1 intervención) el 18/01/2018 19:12:14
Hola compañeros vereis tengo una duda, estoy realizando un programa el cual necesito que adjunte archivos me los muestre en un textarea y luego cunado le de al boton guardar me pregunte la ruta a la cual quiero que me guarde estos archivos adjuntos aqui os dejo las partes de mi codigo a ver si me podeis echar una mano muchisimas gracias de antemano.


1
2
3
ArrayList<String>nombres = new ArrayList<String>();
ArrayList<String>nombres1 = new ArrayList<String>();
ArrayList<String>nombres2 = new ArrayList<String>();

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@FXML private void adSegMercancia(ActionEvent event){
	FileChooser fileChooser = new FileChooser();
	File selectedFile = fileChooser.showOpenDialog(null);
 
	if (selectedFile != null) {
		nombres.add(selectedFile.getName()+"\n");
		//DocMostrar.setText("File selected: " + selectedFile.getName());
		for(int a = 0; a<nombres.size();a++){
			DocMostrar.setText(selectedFile.getName()+"\n");
		}
	}
 
 
}
@FXML private void adFichaTecnica(ActionEvent evetn){
	FileChooser fileChooser = new FileChooser();
	File selectedFile = fileChooser.showOpenDialog(null);
 
	if (selectedFile != null) {
		nombres1.add(selectedFile.getName()+"\n");
		for(int a = 0; a<nombres1.size();a++){
			DocMostrar1.setText(selectedFile.getName()+"\n");
		}
	}
 
}
@FXML private void adTarjTransporte(ActionEvent evetn){
	FileChooser fileChooser = new FileChooser();
	File selectedFile = fileChooser.showOpenDialog(null);
 
	if (selectedFile != null) {
		nombres2.add(selectedFile.getName()+"\n");
		for(int a = 0; a<nombres2.size();a++){
			DocMostrar2.setText(selectedFile.getName()+"\n");
		}
	}
 
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@FXML private void Save(ActionEvent event) {
proveedores Proveedores = new proveedores();
Proveedores.nombrep.set(nombreP.getText());
Proveedores.cifp.set(cifP.getText());
Proveedores.direccionp.set(direccionP.getText());
Proveedores.numerop.set(numeroP.getText());
Proveedores.poblacionp.set(poblacionP.getText());
Proveedores.provinciap.set(provinciaP.getText());
Proveedores.paisp.set(paisP.getText());
Proveedores.cpp.set(cpP.getText());
Proveedores.telefonop.set(telefonoP.getText());
 
proveedores2.add(Proveedores);
 
try
{
    fichero2 = new FileWriter(CsvFile2,true);
    Pw = new PrintWriter(fichero2);
    String aux = Proveedores.getNombrep()+ ";" + Proveedores.getTelefonop() + ";" + Proveedores.getCifp()+";"+Proveedores.getDireccionp()+";"+Proveedores.getNumerop()
    +";"+Proveedores.getPaisp()+";"+Proveedores.getPoblacionp()+";"+Proveedores.getProvinciap()+";"+Proveedores.getCpp();
        Pw.println(aux);
 
} catch (Exception e) {
    e.printStackTrace();
} finally {
   try {
   // Nuevamente aprovechamos el finally para 
   // asegurarnos que se cierra el fichero.
   if (null != fichero2)
      fichero2.close();
   } catch (Exception e2) {
      e2.printStackTrace();
   }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder