回答編集履歴
1
コントローラ全体
test
CHANGED
@@ -8,17 +8,103 @@
|
|
8
8
|
|
9
9
|
```Java
|
10
10
|
|
11
|
-
|
11
|
+
import java.net.URL;
|
12
12
|
|
13
|
-
p
|
13
|
+
import java.util.ResourceBundle;
|
14
14
|
|
15
|
-
selectButton.getItems().forEach(m -> m.setOnAction(event -> {
|
16
15
|
|
17
|
-
MenuItem menuItem = (MenuItem) event.getSource();
|
18
16
|
|
19
|
-
|
17
|
+
import javafx.event.ActionEvent;
|
20
18
|
|
19
|
+
import javafx.event.EventHandler;
|
20
|
+
|
21
|
+
import javafx.fxml.FXML;
|
22
|
+
|
23
|
+
import javafx.fxml.Initializable;
|
24
|
+
|
25
|
+
import javafx.scene.control.MenuItem;
|
26
|
+
|
27
|
+
import javafx.scene.control.SplitMenuButton;
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
public class Controller implements Initializable {
|
32
|
+
|
33
|
+
@FXML
|
34
|
+
|
35
|
+
private SplitMenuButton selectButton;
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
@FXML
|
40
|
+
|
41
|
+
void On_selentButton1(ActionEvent event) {
|
42
|
+
|
43
|
+
// SplitMenuButtonを押したときにテキストによって処理を分岐
|
44
|
+
|
45
|
+
switch (selectButton.getText()) {
|
46
|
+
|
47
|
+
case "全て":
|
48
|
+
|
49
|
+
System.out.println("全て");
|
50
|
+
|
21
|
-
|
51
|
+
break;
|
52
|
+
|
53
|
+
case "未検品":
|
54
|
+
|
55
|
+
System.out.println("未検品");
|
56
|
+
|
57
|
+
break;
|
58
|
+
|
59
|
+
case "検品中":
|
60
|
+
|
61
|
+
System.out.println("検品中");
|
62
|
+
|
63
|
+
break;
|
64
|
+
|
65
|
+
case "検品済":
|
66
|
+
|
67
|
+
System.out.println("検品済");
|
68
|
+
|
69
|
+
break;
|
70
|
+
|
71
|
+
case "中断中":
|
72
|
+
|
73
|
+
System.out.println("中断中");
|
74
|
+
|
75
|
+
break;
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
@Override
|
84
|
+
|
85
|
+
public void initialize(URL location, ResourceBundle resources) {
|
86
|
+
|
87
|
+
// SplitMenuButtonのメニューを選んだ時にテキストを変える
|
88
|
+
|
89
|
+
selectButton.getItems().forEach(m -> m.setOnAction(e -> selectButton.setText(m.getText())));
|
90
|
+
|
91
|
+
// ↑↓同じ意味
|
92
|
+
|
93
|
+
// for (MenuItem menuItem : selectButton.getItems()) {
|
94
|
+
|
95
|
+
// menuItem.setOnAction(new EventHandler<ActionEvent>() {
|
96
|
+
|
97
|
+
// @Override public void handle(ActionEvent event) {
|
98
|
+
|
99
|
+
// selectButton.setText(menuItem.getText());
|
100
|
+
|
101
|
+
// }
|
102
|
+
|
103
|
+
// });
|
104
|
+
|
105
|
+
// }
|
106
|
+
|
107
|
+
}
|
22
108
|
|
23
109
|
}
|
24
110
|
|