前提・実現したいこと
現在、javafxでアプリを作成しています。その中のsetOnActionがうまく作成したイベントハンドラと連動しません。どうしたらよいでしょうか?
発生している問題・エラーメッセージ
Exception in thread "JavaFX Application Thread" java.lang.Error: Unresolved compilation problems: exEventHandler を型に解決できません openEventHandler を型に解決できません hozoEventHandler を型に解決できません deleEventHandler を型に解決できません at saisyuukadai.date1$buEventHandler.handle(date1.java:208) at saisyuukadai.date1$buEventHandler.handle(date1.java:1) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Node.fireEvent(Node.java:8411) at javafx.scene.control.Button.fire(Button.java:185) at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96) at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89) at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238) at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191) at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at javafx.event.Event.fireEvent(Event.java:198) at javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394) at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:432) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431) at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at com.sun.glass.ui.View.notifyMouse(View.java:937) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748)
該当のソースコード
※EventHandlerの中のEventHandlerです
javafx
1class buEventHandler implements EventHandler<ActionEvent>{ 2 public void handle(ActionEvent e5) { 3 stage6 = new Stage(); 4 BorderPane bp =new BorderPane(); 5 ta = new TextArea(); 6 ta.setPrefSize(120,90); 7 FileChooser fc = new FileChooser(); 8 Alert al = new Alert(AlertType.INFORMATION,"",ButtonType.YES,ButtonType.NO); 9 bt1 = new Button("新規"); 10 bt2 = new Button("開く"); 11 bt3 = new Button("保存"); 12 bt4 = new Button("削除"); 13 HBox hb=new HBox(0d); 14 hb.getChildren().add(bt1); 15 hb.getChildren().add(bt2); 16 hb.getChildren().add(bt3); 17 hb.getChildren().add(bt4); 18 hb.setAlignment(Pos.CENTER_RIGHT); 19 //この下の4文が今回の原因です 20 bt1.setOnAction(new exEventHandler()); 21 bt2.setOnAction(new openEventHandler()); 22 bt3.setOnAction(new hozoEventHandler()); 23 bt4.setOnAction(new deleEventHandler()); 24 bp.setCenter(ta); 25 bp.setBottom(hb); 26 Scene sc = new Scene(bp,300,300); 27 stage6.setScene(sc); 28 stage6.setTitle("☆ご自由にお書きください☆"); 29 stage6.show(); 30 class exEventHandler implements EventHandler<ActionEvent>{ 31 public void handle(ActionEvent e5) { 32 al.setTitle("確認"); 33 al.getDialogPane().setContentText("今の記入を中止して、新しいファイルを作りますか?"); 34 if(al.showAndWait().get()== ButtonType.YES) { 35 ta.clear(); 36 } 37 } 38 } 39 class openEventHandler implements EventHandler<ActionEvent>{ 40 public void handle(ActionEvent e5) { 41 File foD = fc.showOpenDialog(null); 42 if(foD != null) { 43 try { 44 FileReader fr = new FileReader(foD); 45 BufferedReader br = new BufferedReader(fr); 46 String lineStr = ""; 47 while((lineStr = br.readLine()) != null) { 48 ta.appendText(lineStr + "/n"); 49 } 50 br.close(); 51 }catch(IOException e) { 52 e.printStackTrace(); 53 } 54 } 55 } 56 } 57 class hozoEventHandler implements EventHandler<ActionEvent>{ 58 public void handle(ActionEvent e5) { 59 al.setTitle("確認"); 60 al.getDialogPane().setContentText("今の記入を中止して、新しいファイルを作りますか?"); 61 } 62 } 63 class deleEventHandler implements EventHandler<ActionEvent>{ 64 public void handle(ActionEvent e5) { 65 al.setTitle("確認"); 66 al.getDialogPane().setContentText("今の記入を中止して、新しいファイルを作りますか?"); 67 } 68 } 69 //保存できる仕組みを作りたい 70 //カレンダーの日付を自動入力できるようにしたい 71 } 72 }
試したこと
EventHandlerの形を治すなどしてみました。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。