質問編集履歴
2
コードとエラーを変更しました。エラーが長すぎて入りきらなかったため、コードを別で載せます
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,243 +13,62 @@
|
|
13
13
|
### 発生している問題・エラーメッセージ
|
14
14
|
|
15
15
|
```
|
16
|
-
Exception in Application start
|
17
|
-
|
18
|
-
at
|
19
|
-
at java.base/java.
|
20
|
-
at javafx.
|
21
|
-
at javafx.
|
22
|
-
at java.base/
|
23
|
-
at java.base/java.
|
24
|
-
at java.base/sun.
|
25
|
-
|
26
|
-
at javafx.
|
27
|
-
at javafx.
|
28
|
-
at java.base/java.
|
29
|
-
|
30
|
-
at javafx.
|
31
|
-
at javafx.base@19/com.sun.javafx.
|
32
|
-
at
|
33
|
-
at javafx.graphics@19/
|
34
|
-
at javafx.
|
35
|
-
at javafx.
|
16
|
+
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: class javafx.scene.control.CheckBox cannot be cast to class javafx.scene.control.TextField (javafx.scene.control.CheckBox and javafx.scene.control.TextField are in module javafx.controls@19 of loader 'app')
|
17
|
+
at Otameshi$MyEventHandler.handle(Otameshi.java:139)
|
18
|
+
at Otameshi$MyEventHandler.handle(Otameshi.java:120)
|
19
|
+
at javafx.base@19/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
|
20
|
+
at javafx.base@19/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
|
21
|
+
at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
|
22
|
+
at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
|
23
|
+
at javafx.base@19/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
|
24
|
+
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
|
25
|
+
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
|
26
|
+
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
|
27
|
+
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
|
28
|
+
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
|
29
|
+
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
|
30
|
+
at javafx.base@19/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
|
31
|
+
at javafx.base@19/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
|
32
|
+
at javafx.base@19/javafx.event.Event.fireEvent(Event.java:198)
|
33
|
+
at javafx.graphics@19/javafx.scene.Node.fireEvent(Node.java:8923)
|
34
|
+
at javafx.controls@19/javafx.scene.control.CheckBox.fire(CheckBox.java:240)
|
35
|
+
at javafx.controls@19/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:207)
|
36
|
+
at javafx.controls@19/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
|
37
|
+
at javafx.base@19/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
|
38
|
+
at javafx.base@19/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
|
39
|
+
at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
|
40
|
+
at javafx.base@19/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
|
41
|
+
at javafx.base@19/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
|
42
|
+
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
|
43
|
+
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
|
44
|
+
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
|
45
|
+
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
|
46
|
+
at javafx.base@19/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
|
47
|
+
at javafx.base@19/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
|
48
|
+
at javafx.base@19/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
|
49
|
+
at javafx.base@19/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
|
50
|
+
at javafx.base@19/javafx.event.Event.fireEvent(Event.java:198)
|
51
|
+
at javafx.graphics@19/javafx.scene.Scene$MouseHandler.process(Scene.java:3894)
|
52
|
+
at javafx.graphics@19/javafx.scene.Scene.processMouseEvent(Scene.java:1887)
|
53
|
+
at javafx.graphics@19/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2620)
|
54
|
+
at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
|
55
|
+
at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
|
36
56
|
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
|
57
|
+
at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
|
37
|
-
at javafx.graphics@19/com.sun.javafx.a
|
58
|
+
at javafx.graphics@19/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
|
59
|
+
at javafx.graphics@19/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
|
38
|
-
at javafx.graphics@19/com.sun.glass.ui.
|
60
|
+
at javafx.graphics@19/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
|
61
|
+
at javafx.graphics@19/com.sun.glass.ui.View.notifyMouse(View.java:937)
|
39
62
|
at javafx.graphics@19/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
|
40
63
|
at javafx.graphics@19/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
|
41
|
-
... 1 more
|
42
|
-
Exception running application Otameshi
|
43
|
-
```
|
44
|
-
|
45
|
-
### 該当のソースコード
|
46
|
-
|
47
|
-
```Java
|
48
|
-
import javafx.application.*;
|
49
|
-
import javafx.scene.*;
|
50
|
-
import javafx.scene.layout.*;
|
51
|
-
import javafx.scene.control.*;
|
52
|
-
import javafx.stage.*;
|
53
|
-
import javafx.event.*;
|
54
|
-
import javafx.geometry.*;
|
55
|
-
import javafx.collections.*;
|
56
|
-
|
57
|
-
public class Otameshi extends Application
|
58
|
-
{
|
59
|
-
private Label resultlb;
|
60
|
-
|
61
|
-
public void start(Stage stage) throws Exception
|
62
|
-
{
|
63
|
-
//ラベルの生成・設定
|
64
|
-
Label[] lb = new Label[3];
|
65
|
-
lb[0] = new Label("課題提出の配点を入力してください");
|
66
|
-
lb[1] = new Label("課題を提出した講義を選択してください");
|
67
|
-
lb[2] = new Label(" ");
|
68
|
-
|
69
|
-
//テキストフィールドを生成/設定します
|
70
|
-
TextField scoretf = new TextField();
|
71
|
-
|
72
|
-
//チェックボックスの生成・設定
|
73
|
-
CheckBox cb1 = new CheckBox("第1回課題");
|
74
|
-
CheckBox cb2 = new CheckBox("第2回課題");
|
75
|
-
CheckBox cb3 = new CheckBox("第3回課題");
|
76
|
-
CheckBox cb4 = new CheckBox("第4回課題");
|
77
|
-
CheckBox cb5 = new CheckBox("第5回課題");
|
78
|
-
CheckBox cb6 = new CheckBox("第6回課題");
|
79
|
-
CheckBox cb7 = new CheckBox("第7回課題");
|
80
|
-
CheckBox cb8 = new CheckBox("第8回課題");
|
81
|
-
CheckBox cb9 = new CheckBox("第9回課題");
|
82
|
-
CheckBox cb10 = new CheckBox("第10回課題");
|
83
|
-
CheckBox cb11 = new CheckBox("第11回課題");
|
84
|
-
CheckBox cb12 = new CheckBox("第12回課題");
|
85
|
-
CheckBox cb13 = new CheckBox("第13回課題");
|
86
|
-
CheckBox cb14 = new CheckBox("第14回課題");
|
87
|
-
CheckBox cb15 = new CheckBox("第15回課題");
|
88
|
-
cb1.setSelected(false);
|
89
|
-
cb2.setSelected(false);
|
90
|
-
cb3.setSelected(false);
|
91
|
-
cb4.setSelected(false);
|
92
|
-
cb5.setSelected(false);
|
93
|
-
cb6.setSelected(false);
|
94
|
-
cb7.setSelected(false);
|
95
|
-
cb8.setSelected(false);
|
96
|
-
cb9.setSelected(false);
|
97
|
-
cb10.setSelected(false);
|
98
|
-
cb11.setSelected(false);
|
99
|
-
cb12.setSelected(false);
|
100
|
-
cb13.setSelected(false);
|
101
|
-
cb14.setSelected(false);
|
102
|
-
cb15.setSelected(false);
|
103
|
-
|
104
|
-
|
105
|
-
//イベントハンドラ設定
|
106
|
-
|
64
|
+
at java.base/java.lang.Thread.run(Thread.java:1589)
|
107
|
-
scoretf.addEventHandler(ActionEvent.ANY, actionhandler);
|
108
|
-
cb1.addEventHandler(ActionEvent.ANY, actionhandler);
|
109
|
-
cb2.addEventHandler(ActionEvent.ANY, actionhandler);
|
110
|
-
cb3.addEventHandler(ActionEvent.ANY, actionhandler);
|
111
|
-
cb4.addEventHandler(ActionEvent.ANY, actionhandler);
|
112
|
-
cb5.addEventHandler(ActionEvent.ANY, actionhandler);
|
113
|
-
cb6.addEventHandler(ActionEvent.ANY, actionhandler);
|
114
|
-
cb7.addEventHandler(ActionEvent.ANY, actionhandler);
|
115
|
-
cb8.addEventHandler(ActionEvent.ANY, actionhandler);
|
116
|
-
cb9.addEventHandler(ActionEvent.ANY, actionhandler);
|
117
|
-
cb10.addEventHandler(ActionEvent.ANY, actionhandler);
|
118
|
-
cb11.addEventHandler(ActionEvent.ANY, actionhandler);
|
119
|
-
cb12.addEventHandler(ActionEvent.ANY, actionhandler);
|
120
|
-
cb13.addEventHandler(ActionEvent.ANY, actionhandler);
|
121
|
-
cb14.addEventHandler(ActionEvent.ANY, actionhandler);
|
122
|
-
cb15.addEventHandler(ActionEvent.ANY, actionhandler);
|
123
|
-
|
124
|
-
//レイアウトの生成・設定
|
125
|
-
VBox vb = new VBox();
|
126
|
-
ObservableList<Node> lst = vb.getChildren();
|
127
|
-
lst.add(lb[0]);
|
128
|
-
lst.add(scoretf);
|
129
|
-
lst.add(lb[1]);
|
130
|
-
lst.add(cb1);
|
131
|
-
lst.add(cb2);
|
132
|
-
lst.add(cb3);
|
133
|
-
lst.add(cb4);
|
134
|
-
lst.add(cb5);
|
135
|
-
lst.add(cb6);
|
136
|
-
lst.add(cb7);
|
137
|
-
lst.add(cb8);
|
138
|
-
lst.add(cb9);
|
139
|
-
lst.add(cb10);
|
140
|
-
lst.add(cb11);
|
141
|
-
lst.add(cb12);
|
142
|
-
lst.add(cb13);
|
143
|
-
lst.add(cb14);
|
144
|
-
lst.add(cb15);
|
145
|
-
lst.add(lb[2]);
|
146
|
-
lst.add(resultlb);
|
147
|
-
|
148
|
-
|
149
|
-
vb.setPadding(new Insets(10));
|
150
|
-
vb.setSpacing(15);
|
151
|
-
|
152
|
-
|
153
|
-
//シーン設定
|
154
|
-
Scene scene = new Scene(vb);
|
155
|
-
|
156
|
-
//ステージ設定
|
157
|
-
stage.setScene(scene);
|
158
|
-
stage.setTitle("成績計算");
|
159
|
-
|
160
|
-
//ステージ表示
|
161
|
-
stage.show();
|
162
|
-
}
|
163
|
-
|
164
|
-
//イベントハンドラクラスの宣言
|
165
|
-
private class MyEventHandler implements EventHandler<ActionEvent>
|
166
|
-
{
|
167
|
-
public void handle(ActionEvent e)
|
168
|
-
{
|
169
|
-
CheckBox cb1 = (CheckBox)e.getTarget();
|
170
|
-
CheckBox cb2 = (CheckBox)e.getTarget();
|
171
|
-
CheckBox cb3 = (CheckBox)e.getTarget();
|
172
|
-
CheckBox cb4 = (CheckBox)e.getTarget();
|
173
|
-
CheckBox cb5 = (CheckBox)e.getTarget();
|
174
|
-
CheckBox cb6 = (CheckBox)e.getTarget();
|
175
|
-
CheckBox cb7 = (CheckBox)e.getTarget();
|
176
|
-
CheckBox cb8 = (CheckBox)e.getTarget();
|
177
|
-
CheckBox cb9 = (CheckBox)e.getTarget();
|
178
|
-
CheckBox cb10 = (CheckBox)e.getTarget();
|
179
|
-
CheckBox cb11 = (CheckBox)e.getTarget();
|
180
|
-
CheckBox cb12 = (CheckBox)e.getTarget();
|
181
|
-
CheckBox cb13 = (CheckBox)e.getTarget();
|
182
|
-
CheckBox cb14 = (CheckBox)e.getTarget();
|
183
|
-
CheckBox cb15 = (CheckBox)e.getTarget();
|
184
|
-
TextField scoretf = (TextField)e.getTarget();
|
185
|
-
double score = 0;
|
186
|
-
double kadai_seiseki = 0;
|
187
|
-
try{
|
188
|
-
score = Double.parseDouble(scoretf.getText());
|
189
|
-
|
190
|
-
if(cb1.isSelected()){
|
191
|
-
kadai_seiseki += (score / 15.0);
|
192
|
-
}
|
193
|
-
if(cb2.isSelected()){
|
194
|
-
kadai_seiseki += (score / 15.0);
|
195
|
-
}
|
196
|
-
if(cb3.isSelected()){
|
197
|
-
kadai_seiseki += (score / 15.0);
|
198
|
-
}
|
199
|
-
if(cb4.isSelected()){
|
200
|
-
kadai_seiseki += (score / 15.0);
|
201
|
-
}
|
202
|
-
if(cb5.isSelected()){
|
203
|
-
kadai_seiseki += (score / 15.0);
|
204
|
-
}
|
205
|
-
if(cb6.isSelected()){
|
206
|
-
kadai_seiseki += (score / 15.0);
|
207
|
-
}
|
208
|
-
if(cb7.isSelected()){
|
209
|
-
kadai_seiseki += (score / 15.0);
|
210
|
-
}
|
211
|
-
if(cb8.isSelected()){
|
212
|
-
kadai_seiseki += (score / 15.0);
|
213
|
-
}
|
214
|
-
if(cb9.isSelected()){
|
215
|
-
kadai_seiseki += (score / 15.0);
|
216
|
-
}
|
217
|
-
if(cb10.isSelected()){
|
218
|
-
kadai_seiseki += (score / 15.0);
|
219
|
-
}
|
220
|
-
if(cb11.isSelected()){
|
221
|
-
kadai_seiseki += (score / 15.0);
|
222
|
-
}
|
223
|
-
if(cb12.isSelected()){
|
224
|
-
kadai_seiseki += (score / 15.0);
|
225
|
-
}
|
226
|
-
if(cb13.isSelected()){
|
227
|
-
kadai_seiseki += (score / 15.0);
|
228
|
-
}
|
229
|
-
if(cb14.isSelected()){
|
230
|
-
kadai_seiseki += (score / 15.0);
|
231
|
-
}
|
232
|
-
if(cb15.isSelected()){
|
233
|
-
kadai_seiseki += (score / 15.0);
|
234
|
-
}
|
235
|
-
}catch(NumberFormatException ee){
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
resultlb.setText("" + kadai_seiseki);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
public static void main(String[] args)
|
243
|
-
{
|
244
|
-
launch(args);
|
245
|
-
}
|
246
|
-
}
|
247
65
|
|
248
66
|
```
|
249
67
|
|
68
|
+
|
250
69
|
### 試したこと
|
251
70
|
|
252
|
-
問題点がどこかわからずいろいろといじりました。
|
71
|
+
問題点がどこかわからずいろいろといじりました。
|
253
72
|
|
254
73
|
### 補足情報(FW/ツールのバージョンなど)
|
255
74
|
openjdk version "19.0.1" 2022-10-18
|
1
バージョンの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -252,6 +252,7 @@
|
|
252
252
|
問題点がどこかわからずいろいろといじりました。そのため、大変醜いコードになってしまいました。
|
253
253
|
|
254
254
|
### 補足情報(FW/ツールのバージョンなど)
|
255
|
-
|
256
|
-
|
255
|
+
openjdk version "19.0.1" 2022-10-18
|
257
|
-
|
256
|
+
OpenJDK Runtime Environment (build 19.0.1+10-21)
|
257
|
+
OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
|
258
|
+
|