###前提・実現したいこと
NetBeans上でメソッドだけページを分けて書きたい
自作関数(メソッド)Startup()内でtheStgaeを使いたい
です
プログラム自体初心者なもので初歩的な質問すみません
###発生している問題・エラーメッセージ
java
1package novelgame; 2 3import java.util.ArrayList; 4import javafx.animation.AnimationTimer; 5import javafx.application.Application; 6import javafx.event.EventHandler; 7import javafx.scene.Group; 8import javafx.scene.Scene; 9import javafx.scene.input.KeyEvent; 10import javafx.scene.input.MouseEvent; 11import javafx.stage.Stage; 12 13public class Setup extends Application 14{ 15 int num = 1; 16 double mw,mv,pw,pv= 0; 17 ArrayList<String> keyarry = new ArrayList<String>(); 18 public Stage theStage = new Stage(); 19 String a = "q"; 20 21 public static void main(String[] args) 22 { 23 launch(args); 24 } 25 26 @Override public void start(Stage theStage) 27 { 28 Group root = new Group(); 29 Scene theScene = new Scene(root); 30 31 new AnimationTimer(){ 32 @Override 33 public void handle(long now) 34 { 35 36 switch (num) 37 { 38 case 1: 39 num = num + 1; 40 Startup(); 41 System.out.println("1"); 42 theStage.setScene(theScene); 43 44 break; 45 case 2: 46 47 break; 48 case 3: 49 50 break; 51 case 4: 52 53 break; 54 case 5: 55 56 break; 57 } 58 } 59 } 60 61//マウス 62 theScene.setOnMouseMoved( 63 new EventHandler<MouseEvent>() 64 { 65 public void handle(MouseEvent e) 66 { 67 mw=e.getX(); 68 mv=e.getY(); 69 System.out.println("Move X=" + mw + " Y=" + mv); 70 } 71 }); 72 73 theScene.setOnMouseClicked( 74 new EventHandler<MouseEvent>() 75 { 76 public void handle(MouseEvent ce) 77 { 78 pw=ce.getX(); 79 pv=ce.getY(); 80 System.out.println("Push X=" + pw + " Y=" + pv); 81 } 82 }); 83 84//キー 85 theScene.setOnKeyPressed( 86 new EventHandler<KeyEvent>() 87 { 88 public void handle(KeyEvent pe) 89 { 90 String code = pe.getCode().toString(); 91 if ( !keyarry.contains(code) ) 92 keyarry.add(code); 93 94 System.out.print("push"); 95 System.out.println(code); 96 } 97 }); 98 99 theScene.setOnKeyReleased( 100 new EventHandler<KeyEvent>() 101 { 102 public void handle(KeyEvent re) 103 { 104 String code1 = re.getCode().toString(); 105 keyarry.remove( code1 ); 106 107 System.out.print("remove"); 108 System.out.println(code1); 109 110 } 111 }); 112 113 theStage.show(); 114 } 115 116 void Startup() 117 { 118 //画像のロードなど 119 theStage.setTitle("testseikou"); 120 121 } 122 123}
window名が"testseikou"に変更されませんでした
###試したこと
public Stage theStage = new Stage();と先にインスタンスを作成しました
###補足情報(言語/FW/ツール等のバージョンなど)
macでのNetBeans 8.2環境
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/20 09:29