回答編集履歴
1
コード意図明確化
answer
CHANGED
|
@@ -11,33 +11,25 @@
|
|
|
11
11
|
|
|
12
12
|
```java
|
|
13
13
|
import javafx.application.Application;
|
|
14
|
-
import javafx.collections.ObservableMap;
|
|
15
|
-
import javafx.event.Event;
|
|
16
|
-
import javafx.event.EventHandler;
|
|
17
|
-
import javafx.fxml.FXMLLoader;
|
|
18
14
|
import javafx.scene.Scene;
|
|
19
15
|
import javafx.scene.control.*;
|
|
20
16
|
import javafx.scene.input.*;
|
|
21
17
|
import javafx.scene.layout.BorderPane;
|
|
22
|
-
import javafx.stage.FileChooser;
|
|
23
18
|
import javafx.stage.Stage;
|
|
24
19
|
|
|
25
|
-
import java.io.File;
|
|
26
|
-
import java.io.IOException;
|
|
27
|
-
|
|
28
20
|
public class HelloApplication extends Application {
|
|
29
21
|
public static void main(String[] args) { launch(); }
|
|
30
22
|
|
|
31
23
|
public void start(final Stage stage) {
|
|
32
24
|
stage.addEventFilter(KeyEvent.ANY, event -> {
|
|
33
|
-
if (event.getCode() == KeyCode.ALT || event.getCode() == KeyCode.ALT_GRAPH) {
|
|
34
|
-
event.consume();
|
|
35
|
-
System.out.println("ALT " + event.getEventType());
|
|
36
|
-
}
|
|
37
25
|
if (event.isAltDown()) {
|
|
38
26
|
event.consume();
|
|
39
27
|
System.out.println("isAltDown " + event.getCode());
|
|
40
28
|
}
|
|
29
|
+
// if (event.getCode() == KeyCode.ALT || event.getCode() == KeyCode.ALT_GRAPH) {
|
|
30
|
+
// event.consume();
|
|
31
|
+
// System.out.println("ALT " + event.getEventType());
|
|
32
|
+
// }
|
|
41
33
|
});
|
|
42
34
|
|
|
43
35
|
var menuBar = new MenuBar(
|
|
@@ -52,6 +44,8 @@
|
|
|
52
44
|
root.setTop(menuBar);
|
|
53
45
|
|
|
54
46
|
var scene = new Scene(root);
|
|
47
|
+
// scene.addEventFilter(... ではうまくいかんかった
|
|
48
|
+
|
|
55
49
|
stage.setScene(scene);
|
|
56
50
|
stage.setWidth(300);
|
|
57
51
|
stage.setHeight(200);
|