我正在尝试使用方法“ getAbsolutePath()”,但我一直在收到错误消息:找不到符号。这是我的使用方式:错误:找不到符号
:错误:找不到符号System.out.println(sneakers_application.selectedFileXML.getAbsolutePath()); 符号:class selectedFileXML
我试图在同一个班级中拥有一切
public class Sneakers_application extends Application {
public static File selectedFileXLSX, selectedFileTXT, selectedFileXML, selectedFileMySQL;
@Override
public void start(Stage primaryStage) {
// DAO_Sneakers daoSneaker = Factory.getDAOInstance(DAO_DB_TYPE.TEXTFILE);
//DAO_Sneakers daoSneaker = Factory.getDAOInstance(DAO_DB_TYPE.EXCEL);
//DAO_Sneakers daoSneaker = Factory.getDAOInstance(DAO_DB_TYPE.MYSQL);
//DAO_Sneakers daoSneaker = Factory.getDAOInstance(DAO_DB_TYPE.XML);
Scene scene = new Scene(new Sneakers_Gui(daoSneaker));
primaryStage.setTitle("sneakersnstuff");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
public class MenuListener implements EventHandler {
@Override
public void handle(Event event) {
MenuItem item = (MenuItem) event.getSource();
switch (item.getText()) {
case "Excel file":
daoSneaker = (DAO_Sneakers) Factory.getDAOInstance(DAO_DB_TYPE.EXCEL);
FileChooser fc = new FileChooser();
fc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Excel", "*.xlsx"));
Sneakers_application.selectedFileXLSX = fc.showOpenDialog(null);
System.out.println(sneakers_application.selectedFileXLSX.getAbsolutePath());
obsListSneaker.setAll(daoSneaker.getSneaker());
obsListModell.setAll(modellList());
break;
case "Text file":
daoSneaker = (DAO_Sneakers) Factory.getDAOInstance(DAO_DB_TYPE.TEXTFILE);
fc = new FileChooser();
fc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Textfile", "*.txt"));
Sneakers_application.selectedFileTXT = fc.showOpenDialog(null);
System.out.println(sneakers_application.selectedFileTXT.getAbsolutePath());
obsListSneaker.setAll(daoSneaker.getSneaker());
obsListModell.setAll(modellList());
break;
case "XML file":
daoSneaker = (DAO_Sneakers) Factory.getDAOInstance(DAO_DB_TYPE.XML);
fc = new FileChooser();
fc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Xml", "*.xml"));
Sneakers_application.selectedFileXML = fc.showOpenDialog(null);
System.out.println(sneakers_application.selectedFileXML.getAbsolutePath());
obsListSneaker.setAll(daoSneaker.getSneaker());
obsListModell.setAll(modellList());
break;
case "MySQL":
daoSneaker = (DAO_Sneakers) Factory.getDAOInstance(DAO_DB_TYPE.MYSQL);
obsListSneaker.setAll(daoSneaker.getSneaker());
obsListModell.setAll(modellList());
break;
case "Backup to XML":
backup.deleteXML();
backup.backupToXML();
}
}
}