質問編集履歴
1
説明の不足
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,9 +82,107 @@
|
|
82
82
|
|
83
83
|
### 試したこと
|
84
84
|
|
85
|
+
プログラムが長いので、プログラムにエラーが起きた1歩手前の行動につき、プログラムを割愛させて頂きます。(全文が必要な場合は、言って頂けると助かります)
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
class meEventHandler implements EventHandler<ActionEvent>{
|
90
|
+
|
91
|
+
public void handle(ActionEvent e3) {
|
92
|
+
|
93
|
+
stage4 = new Stage();
|
94
|
+
|
95
|
+
lb = new Label("");
|
96
|
+
|
97
|
+
ch1 = new CheckBox("水やり");
|
98
|
+
|
99
|
+
ch2 = new CheckBox("晴れ");
|
100
|
+
|
101
|
+
bt1 = new Button("設定");
|
102
|
+
|
103
|
+
BorderPane bp =new BorderPane();
|
104
|
+
|
105
|
+
VBox hb = new VBox();
|
106
|
+
|
107
|
+
VBox hb1 = new VBox();
|
108
|
+
|
109
|
+
hb.getChildren().add(ch1);
|
110
|
+
|
111
|
+
hb.getChildren().add(ch2);
|
112
|
+
|
113
|
+
hb.setAlignment(Pos.CENTER);
|
114
|
+
|
115
|
+
hb1.getChildren().add(lb);
|
116
|
+
|
117
|
+
hb1.getChildren().add(bt1);
|
118
|
+
|
119
|
+
hb1.setAlignment(Pos.CENTER);
|
120
|
+
|
121
|
+
bt1.setOnAction(new installEventHandler());
|
122
|
+
|
123
|
+
bp.setLeft(hb);
|
124
|
+
|
125
|
+
bp.setCenter(hb1);
|
126
|
+
|
127
|
+
Scene sc = new Scene(bp, 400, 400);
|
128
|
+
|
129
|
+
stage4.setScene(sc);
|
130
|
+
|
131
|
+
stage4.show();
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
//ここの画像読み込みの役割のイベントハンドラを試験的に追加して、消したら上記のようなエラーが出ました。
|
138
|
+
|
139
|
+
class installEventHandler implements EventHandler<ActionEvent>{
|
140
|
+
|
141
|
+
public void handle(ActionEvent e) {
|
142
|
+
|
143
|
+
try{
|
85
144
|
|
86
145
|
|
146
|
+
|
147
|
+
//not embedded resource. doesn't work when packaged in jar
|
148
|
+
|
149
|
+
File file = new File("black_dot.png");
|
150
|
+
|
151
|
+
Image imageFromProjectFolder = new Image(file.toURI().toString());//or new Image(new FileInputStream("black_dot.png"));
|
152
|
+
|
153
|
+
ImageView view1 = new ImageView(imageFromProjectFolder);
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
URL url = getClass().getResource("red_dot.png");
|
158
|
+
|
159
|
+
Image imageFromSourceFolder = new Image(url.openStream());
|
160
|
+
|
161
|
+
ImageView view2 = new ImageView(imageFromSourceFolder); //or new ImageView("/package/red_dot.png");
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
url = getClass().getResource("/resources/blue_dot.png");
|
166
|
+
|
167
|
+
Image imageFromReourceFolder = new Image(url.openStream());
|
168
|
+
|
169
|
+
ImageView view3 = new ImageView(imageFromReourceFolder); //or new ImageView("/resources/blue_dot.png");
|
170
|
+
|
171
|
+
|
172
|
+
|
87
|
-
|
173
|
+
pane = new TilePane(view1, view2, view3);
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
} catch (Exception ex) {ex.printStackTrace();}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
```
|
88
186
|
|
89
187
|
|
90
188
|
|