質問編集履歴
2
timer class のダブルコロンの使い方について
title
CHANGED
File without changes
|
body
CHANGED
@@ -220,7 +220,26 @@
|
|
220
220
|
new View5(new Controller(new Model()));
|
221
221
|
}
|
222
222
|
}
|
223
|
+
```
|
224
|
+
###
|
225
|
+
上のプログラムはmvcモデルで構築しています。
|
223
226
|
|
227
|
+
###追加の質問
|
228
|
+
|
229
|
+
|
224
230
|
```
|
231
|
+
timer = new Timer(1000,this::expired);
|
225
|
-
|
232
|
+
```
|
233
|
+
のところですが、調べてみて"::"の使い方は理解できたのですが、コンパイルがここだけできないです。エラー文は
|
234
|
+
```
|
235
|
+
View5.java:63: エラー: ')'がありません
|
236
|
+
timer = new Timer(1000,this::expired);
|
237
|
+
^
|
238
|
+
View5.java:63: エラー: 式の開始が不正です
|
239
|
+
timer = new Timer(1000,this::expired);
|
240
|
+
^
|
241
|
+
View5.java:63: エラー: ';'がありません
|
242
|
+
timer = new Timer(1000,this::expired);
|
243
|
+
|
244
|
+
```
|
226
|
-
|
245
|
+
となっています。javaのバージョンの問題でしょうか。
|
1
entiredでなくexpiredですね、すいません
title
CHANGED
File without changes
|
body
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
boolean flushFlag;
|
65
65
|
public Controller(Model model){
|
66
66
|
this.model=model;
|
67
|
-
timer = new Timer(1000, this::
|
67
|
+
timer = new Timer(1000, this::expired);
|
68
68
|
timer.setRepeats(true);
|
69
69
|
}
|
70
70
|
|
@@ -97,7 +97,7 @@
|
|
97
97
|
timer.start();
|
98
98
|
}
|
99
99
|
|
100
|
-
void
|
100
|
+
void expired(ActionEvent ev/*actionEventでもだめだした*/) {
|
101
101
|
flushFlag = !flushFlag;
|
102
102
|
flushButton.setBackground(flushFlag ? defaultColor : flushColor);
|
103
103
|
flushButton.repaint();
|