netbeans - How to display an image chosen with filechooser Javafx FXML -


i have gotten program allow me browse file select using file chooser. see method in code below. problem not know next. want assign file chosen image file. want display image(only image files used in program).

since using scene builder, contains actual application(paint) class fxml controller class, believe have add code both classes. have attached both clarity sake.

public class fxmldocumentcontroller implements initializable {   @fxml private menuitem open; private menuitem exit; private anchorpane pane; private imageview imgv; private stage primarystage;   @fxml private void handleopenaction() {      filechooser filechooser = new filechooser();     filechooser.extensionfilter extfilterjpg = new filechooser.extensionfilter("jpg files (*.jpg)", "*.jpg");     filechooser.extensionfilter extfilterpng = new filechooser.extensionfilter("png files (*.png)", "*.png");     file file = filechooser.showopendialog(primarystage);   } @fxml private void handleexitaction(){             system.exit(0);  }   @override public void initialize(url url, resourcebundle rb) {  }        }   public class paint extends application {  @override public void start(stage stage) throws exception {     parent root = fxmlloader.load(getclass().getresource("fxmldocument.fxml"));     scene scene = new scene(root, 400, 600);     stage.settitle("paint");     stage.setscene(scene);     stage.show();       }  public static void main(string[] args) {     launch(args); } 

i don't mind loading image default program pane, must able "draw" on image later on down road.

  1. how get/set image selected via filechooser?
    • do inside same fxml method or make separate method?
  2. how display image?
    • should creating pane image load manually inside fxml class or inside paint class?
  3. is there way create (choose, get, set) method add paint class can referenced inside fxml class?

  4. i aware must assign scene builder elements fxml handles/methods them function properly.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -