Problems when trying to upload an xml file into the program [on hold]

316
March 16, 2017, at 03:31 AM

My goal is to browse the computer and from the computer to get the file that the user wants.But I am incapable of doing it as you can't return things into the setOnAction method.Any tips?

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Document document= new Document;
        Builder build= new Builder();
        Button btn= new Button("select file");
        Button btn1= new Button("Searching");
        Button btn2= new Button("Replace");
        Button btn3= new Button("Replace");
        Button save= new Button("Save")
        btn.setOnAction(new  EventHandler<ActionEvent>(){
            @Override
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Open Resource File");
            fileChooser.getExtensionFilters().addAll(new            FileChooser.ExtensionFilter("XML Files", "*.xml"));
                File selectedFile = fileChooser.showOpenDialog(stage);
                try{
                    return selectedFile.getAbsolutePath();}
                catch (NullPointerException e){
                        return null;
                    }
                    }
                }
            });
        save.setOnAction(new  EventHandler<ActionEvent>(){
            @Override
            FileChooser fileChooser = new FileChooser();
                fileChooser.setTitle("Save XML File");
                fileChooser.getExtensionFilters().addAll(newFileChooser.ExtensionFilter("XML Files", "*.xml"));
                fileChooser.setInitialFileName("hamlet.xml");
             File selectedFile = fileChooser.showSaveDialog(stage);
                try{
                    return selectedFile.getAbsolutePath();}
                catch (NullPointerException e)}
                    return null;
                    }
            });

        Pane root= new Pane();
        btn.setLayoutX(250);
        btn.setLayoutY(100);
        save.setLayoutX(250);
        save.setLayoutY(200);
        root.getChildren().add(btn);
        root.getChildren().add(save);
        Scene scene= new Scene(root,500,600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }
}
Rent Charter Buses Company
READ ALSO
Have all endpoints in same path and declared ending path inside header

Have all endpoints in same path and declared ending path inside header

I have one endpoint for all app like https://localhost:8080/test and inside header I have parameter with rest of URLDo you know how can make this work in java/spring proyect?

352
Android no Activity Found to Handle Intent MediaScanner

Android no Activity Found to Handle Intent MediaScanner

im trying to open a Gallery with Images/Videos from a specific FolderIĀ“m using this solution but im getting the error code below and nothing happens

623
libgdx stage not working right

libgdx stage not working right

I am working on a gaming app in android studio but my hud code isn't working properlyWhen I try to add my third table to the stage, actionButtons, it is positioning same as my second table, control, even though I have both of them specified for different...

532
JPA createNativeQuery with column name (and table name) as parameter

JPA createNativeQuery with column name (and table name) as parameter

It is possible to set column name (or table name) as parameter in JPA, like :

617