質問編集履歴
7
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,169 +3,3 @@
|
|
3
3
|
メニューバーによってボタンを作成したいのですが型に解決できないとはどういう意味でしょうか( ; ; )
|
4
4
|
|
5
5
|
初心者のためテキストを見てもよく理解できず、、
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
```Java
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
コード```import javafx.application.Application;
|
14
|
-
|
15
|
-
import javafx.scene.Group;
|
16
|
-
|
17
|
-
import javafx.scene.Scene;
|
18
|
-
|
19
|
-
import javafx.scene.canvas.Canvas;
|
20
|
-
|
21
|
-
import javafx.scene.canvas.GraphicsContext;
|
22
|
-
|
23
|
-
import javafx.scene.input.MouseEvent;
|
24
|
-
|
25
|
-
import javafx.stage.Stage;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
public class MyApp extends Application {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
GraphicsContext g;
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
public void start(Stage stage) {
|
38
|
-
|
39
|
-
stage.setWidth(400);
|
40
|
-
|
41
|
-
stage.setHeight(400);
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
Canvas canvas = new Canvas(400, 400);
|
46
|
-
|
47
|
-
g = canvas.getGraphicsContext2D();
|
48
|
-
|
49
|
-
g.setLineWidth(3);
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
MenuBar menuBar = new MenuBar();
|
54
|
-
|
55
|
-
Menu colorMenu = new Menu("Color");
|
56
|
-
|
57
|
-
MenuItem menuColor1 = new MenuItem(" ");
|
58
|
-
|
59
|
-
MenuItem menuColor2 = new MenuItem(" ");
|
60
|
-
|
61
|
-
MenuItem menuColor3 = new MenuItem(" ");
|
62
|
-
|
63
|
-
MenuItem menuColor4 = new MenuItem(" ");
|
64
|
-
|
65
|
-
MenuItem menuColor5 = new MenuItem(" ");
|
66
|
-
|
67
|
-
MenuItem menuColor6 = new MenuItem(" ");
|
68
|
-
|
69
|
-
MenuItem menuColor7 = new MenuItem(" ");
|
70
|
-
|
71
|
-
MenuItem menuColor8 = new MenuItem(" ");
|
72
|
-
|
73
|
-
MenuItem menuColor9 = new MenuItem(" ");
|
74
|
-
|
75
|
-
MenuItem menuColor10 = new MenuItem(" ");
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
fileMenu.getItems().add(menuColor1);
|
80
|
-
|
81
|
-
fileMenu.getItems().add(menuColor2);
|
82
|
-
|
83
|
-
fileMenu.getItems().add(menuColor3);
|
84
|
-
|
85
|
-
fileMenu.getItems().add(menuColor4);
|
86
|
-
|
87
|
-
fileMenu.getItems().add(menuColor5);
|
88
|
-
|
89
|
-
fileMenu.getItems().add(menuColor6);
|
90
|
-
|
91
|
-
fileMenu.getItems().add(menuColor7);
|
92
|
-
|
93
|
-
fileMenu.getItems().add(menuColor8);
|
94
|
-
|
95
|
-
fileMenu.getItems().add(menuColor9);
|
96
|
-
|
97
|
-
fileMenu.getItems().add(menuColor10);
|
98
|
-
|
99
|
-
menuBar.getMenus().add(colorMenu);
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
MenuBar menuBar1 = new MenuBar1();
|
104
|
-
|
105
|
-
Menu widthMenu = new Menu("Width");
|
106
|
-
|
107
|
-
MenuItem menuWidth1 = new MenuItem("細" );
|
108
|
-
|
109
|
-
MenuItem menuWidth2 = new MenuItem("中") ;
|
110
|
-
|
111
|
-
MenuItem menuWidth3 = new MenuItem("太") ;
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
fileMenu.getItems().add(menuWidth1);
|
116
|
-
|
117
|
-
fileMenu.getItems().add(menuWidth2);
|
118
|
-
|
119
|
-
fileMenu.getItems().add(menuWidth3);
|
120
|
-
|
121
|
-
menuBar.getMenus().add(widthMenu);
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
canvas.setOnMousePressed(event -> mousePressed(event));
|
126
|
-
|
127
|
-
canvas.setOnMouseDragged(event -> mouseDragged(event));
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
Group root = new Group();
|
132
|
-
|
133
|
-
root.set(menuBar,menuBar1);
|
134
|
-
|
135
|
-
root.getChildren().add(canvas);
|
136
|
-
|
137
|
-
stage.setScene(new Scene(root));
|
138
|
-
|
139
|
-
stage.show();
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
void mousePressed(MouseEvent event) {
|
148
|
-
|
149
|
-
g.moveTo(event.getX(), event.getY());
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
void mouseDragged(MouseEvent event) {
|
156
|
-
|
157
|
-
g.lineTo(event.getX(), event.getY());
|
158
|
-
|
159
|
-
g.stroke();
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
public static void main(String[] args) {
|
166
|
-
|
167
|
-
launch();
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
}
|
6
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,9 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
コード
|
14
|
-
|
15
|
-
```import javafx.application.Application;
|
13
|
+
コード```import javafx.application.Application;
|
16
14
|
|
17
15
|
import javafx.scene.Group;
|
18
16
|
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
```Java
|
10
|
+
|
11
|
+
|
10
12
|
|
11
13
|
コード
|
12
14
|
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,9 +10,7 @@
|
|
10
10
|
|
11
11
|
コード
|
12
12
|
|
13
|
-
```
|
14
|
-
|
15
|
-
import javafx.application.Application;
|
13
|
+
```import javafx.application.Application;
|
16
14
|
|
17
15
|
import javafx.scene.Group;
|
18
16
|
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,79 +6,75 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
```Java
|
10
10
|
|
11
|
-
|
11
|
+
コード
|
12
12
|
|
13
|
-
|
13
|
+
```
|
14
14
|
|
15
|
-
import
|
15
|
+
import javafx.application.Application;
|
16
16
|
|
17
|
-
import
|
17
|
+
import javafx.scene.Group;
|
18
18
|
|
19
|
-
import
|
19
|
+
import javafx.scene.Scene;
|
20
20
|
|
21
|
-
import
|
21
|
+
import javafx.scene.canvas.Canvas;
|
22
22
|
|
23
|
-
|
23
|
+
import javafx.scene.canvas.GraphicsContext;
|
24
24
|
|
25
|
-
p
|
25
|
+
import javafx.scene.input.MouseEvent;
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
GraphicsContext g;
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
27
|
+
import javafx.stage.Stage;
|
40
|
-
|
41
|
-
stage.setWidth(400);
|
42
|
-
|
43
|
-
stage.setHeight(400);
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Canvas canvas = new Canvas(400, 400);
|
52
|
-
|
53
|
-
g = canvas.getGraphicsContext2D();
|
54
|
-
|
55
|
-
g.setLineWidth(3);
|
56
28
|
|
57
29
|
|
58
30
|
|
59
|
-
|
31
|
+
public class MyApp extends Application {
|
60
32
|
|
61
|
-
Menu colorMenu = new Menu("Color");
|
62
33
|
|
63
|
-
MenuItem menuColor1 = new MenuItem(" ");
|
64
34
|
|
65
|
-
|
35
|
+
GraphicsContext g;
|
66
36
|
|
67
|
-
MenuItem menuColor3 = new MenuItem(" ");
|
68
37
|
|
69
|
-
MenuItem menuColor4 = new MenuItem(" ");
|
70
38
|
|
71
|
-
|
39
|
+
public void start(Stage stage) {
|
72
40
|
|
73
|
-
|
41
|
+
stage.setWidth(400);
|
74
42
|
|
75
|
-
|
43
|
+
stage.setHeight(400);
|
76
44
|
|
77
|
-
MenuItem menuColor8 = new MenuItem(" ");
|
78
45
|
|
79
|
-
MenuItem menuColor9 = new MenuItem(" ");
|
80
46
|
|
47
|
+
Canvas canvas = new Canvas(400, 400);
|
48
|
+
|
49
|
+
g = canvas.getGraphicsContext2D();
|
50
|
+
|
51
|
+
g.setLineWidth(3);
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
MenuBar menuBar = new MenuBar();
|
56
|
+
|
57
|
+
Menu colorMenu = new Menu("Color");
|
58
|
+
|
59
|
+
MenuItem menuColor1 = new MenuItem(" ");
|
60
|
+
|
61
|
+
MenuItem menuColor2 = new MenuItem(" ");
|
62
|
+
|
63
|
+
MenuItem menuColor3 = new MenuItem(" ");
|
64
|
+
|
65
|
+
MenuItem menuColor4 = new MenuItem(" ");
|
66
|
+
|
67
|
+
MenuItem menuColor5 = new MenuItem(" ");
|
68
|
+
|
69
|
+
MenuItem menuColor6 = new MenuItem(" ");
|
70
|
+
|
71
|
+
MenuItem menuColor7 = new MenuItem(" ");
|
72
|
+
|
73
|
+
MenuItem menuColor8 = new MenuItem(" ");
|
74
|
+
|
75
|
+
MenuItem menuColor9 = new MenuItem(" ");
|
76
|
+
|
81
|
-
MenuItem
|
77
|
+
MenuItem menuColor10 = new MenuItem(" ");
|
82
78
|
|
83
79
|
|
84
80
|
|
@@ -106,15 +102,15 @@
|
|
106
102
|
|
107
103
|
|
108
104
|
|
109
|
-
MenuBar
|
105
|
+
MenuBar menuBar1 = new MenuBar1();
|
110
106
|
|
111
|
-
Menu
|
107
|
+
Menu widthMenu = new Menu("Width");
|
112
108
|
|
113
|
-
MenuItem
|
109
|
+
MenuItem menuWidth1 = new MenuItem("細" );
|
114
110
|
|
115
|
-
MenuItem
|
111
|
+
MenuItem menuWidth2 = new MenuItem("中") ;
|
116
112
|
|
117
|
-
MenuItem
|
113
|
+
MenuItem menuWidth3 = new MenuItem("太") ;
|
118
114
|
|
119
115
|
|
120
116
|
|
@@ -128,64 +124,50 @@
|
|
128
124
|
|
129
125
|
|
130
126
|
|
127
|
+
canvas.setOnMousePressed(event -> mousePressed(event));
|
128
|
+
|
129
|
+
canvas.setOnMouseDragged(event -> mouseDragged(event));
|
131
130
|
|
132
131
|
|
133
132
|
|
133
|
+
Group root = new Group();
|
134
134
|
|
135
|
-
|
135
|
+
root.set(menuBar,menuBar1);
|
136
|
+
|
137
|
+
root.getChildren().add(canvas);
|
138
|
+
|
139
|
+
stage.setScene(new Scene(root));
|
140
|
+
|
141
|
+
stage.show();
|
136
142
|
|
137
143
|
|
138
144
|
|
139
|
-
|
145
|
+
}
|
140
|
-
|
141
|
-
canvas.setOnMouseDragged(event -> mouseDragged(event));
|
142
146
|
|
143
147
|
|
144
148
|
|
145
|
-
|
149
|
+
void mousePressed(MouseEvent event) {
|
146
150
|
|
147
|
-
|
151
|
+
g.moveTo(event.getX(), event.getY());
|
152
|
+
|
153
|
+
}
|
148
154
|
|
149
155
|
|
150
156
|
|
151
|
-
|
157
|
+
void mouseDragged(MouseEvent event) {
|
152
158
|
|
153
|
-
|
159
|
+
g.lineTo(event.getX(), event.getY());
|
154
160
|
|
155
|
-
|
161
|
+
g.stroke();
|
156
162
|
|
157
|
-
stage.setScene(new Scene(root));
|
158
|
-
|
159
|
-
stage.show();
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
163
|
+
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
void mousePressed(MouseEvent event) {
|
168
|
-
|
169
|
-
g.moveTo(event.getX(), event.getY());
|
170
|
-
|
171
|
-
}
|
172
164
|
|
173
165
|
|
174
166
|
|
175
|
-
|
167
|
+
public static void main(String[] args) {
|
176
168
|
|
177
|
-
|
169
|
+
launch();
|
178
170
|
|
179
|
-
|
171
|
+
}
|
180
172
|
|
181
|
-
|
173
|
+
}
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
public static void main(String[] args) {
|
186
|
-
|
187
|
-
launch();
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
}
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Javafxを用いてペイントを作ろうとしています。
|
2
2
|
|
3
|
-
メニューバーによってボタンを作成したいのですが
|
3
|
+
メニューバーによってボタンを作成したいのですが型に解決できないとはどういう意味でしょうか( ; ; )
|
4
4
|
|
5
5
|
初心者のためテキストを見てもよく理解できず、、
|
6
6
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,3 +3,189 @@
|
|
3
3
|
メニューバーによってボタンを作成したいのですがこの型に解決できないとはどういう意味でしょうか( ; ; )
|
4
4
|
|
5
5
|
初心者のためテキストを見てもよく理解できず、、
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
import javafx.application.Application;
|
10
|
+
|
11
|
+
import javafx.scene.Group;
|
12
|
+
|
13
|
+
import javafx.scene.Scene;
|
14
|
+
|
15
|
+
import javafx.scene.canvas.Canvas;
|
16
|
+
|
17
|
+
import javafx.scene.canvas.GraphicsContext;
|
18
|
+
|
19
|
+
import javafx.scene.input.MouseEvent;
|
20
|
+
|
21
|
+
import javafx.stage.Stage;
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
public class MyApp extends Application {
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
GraphicsContext g;
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
public void start(Stage stage) {
|
40
|
+
|
41
|
+
stage.setWidth(400);
|
42
|
+
|
43
|
+
stage.setHeight(400);
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
Canvas canvas = new Canvas(400, 400);
|
52
|
+
|
53
|
+
g = canvas.getGraphicsContext2D();
|
54
|
+
|
55
|
+
g.setLineWidth(3);
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
MenuBar menuBar = new MenuBar();
|
60
|
+
|
61
|
+
Menu colorMenu = new Menu("Color");
|
62
|
+
|
63
|
+
MenuItem menuColor1 = new MenuItem(" ");
|
64
|
+
|
65
|
+
MenuItem menuColor2 = new MenuItem(" ");
|
66
|
+
|
67
|
+
MenuItem menuColor3 = new MenuItem(" ");
|
68
|
+
|
69
|
+
MenuItem menuColor4 = new MenuItem(" ");
|
70
|
+
|
71
|
+
MenuItem menuColor5 = new MenuItem(" ");
|
72
|
+
|
73
|
+
MenuItem menuColor6 = new MenuItem(" ");
|
74
|
+
|
75
|
+
MenuItem menuColor7 = new MenuItem(" ");
|
76
|
+
|
77
|
+
MenuItem menuColor8 = new MenuItem(" ");
|
78
|
+
|
79
|
+
MenuItem menuColor9 = new MenuItem(" ");
|
80
|
+
|
81
|
+
MenuItem menuColor10 = new MenuItem(" ");
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
fileMenu.getItems().add(menuColor1);
|
86
|
+
|
87
|
+
fileMenu.getItems().add(menuColor2);
|
88
|
+
|
89
|
+
fileMenu.getItems().add(menuColor3);
|
90
|
+
|
91
|
+
fileMenu.getItems().add(menuColor4);
|
92
|
+
|
93
|
+
fileMenu.getItems().add(menuColor5);
|
94
|
+
|
95
|
+
fileMenu.getItems().add(menuColor6);
|
96
|
+
|
97
|
+
fileMenu.getItems().add(menuColor7);
|
98
|
+
|
99
|
+
fileMenu.getItems().add(menuColor8);
|
100
|
+
|
101
|
+
fileMenu.getItems().add(menuColor9);
|
102
|
+
|
103
|
+
fileMenu.getItems().add(menuColor10);
|
104
|
+
|
105
|
+
menuBar.getMenus().add(colorMenu);
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
MenuBar menuBar1 = new MenuBar1();
|
110
|
+
|
111
|
+
Menu widthMenu = new Menu("Width");
|
112
|
+
|
113
|
+
MenuItem menuWidth1 = new MenuItem("細" );
|
114
|
+
|
115
|
+
MenuItem menuWidth2 = new MenuItem("中") ;
|
116
|
+
|
117
|
+
MenuItem menuWidth3 = new MenuItem("太") ;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
fileMenu.getItems().add(menuWidth1);
|
122
|
+
|
123
|
+
fileMenu.getItems().add(menuWidth2);
|
124
|
+
|
125
|
+
fileMenu.getItems().add(menuWidth3);
|
126
|
+
|
127
|
+
menuBar.getMenus().add(widthMenu);
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
canvas.setOnMousePressed(event -> mousePressed(event));
|
140
|
+
|
141
|
+
canvas.setOnMouseDragged(event -> mouseDragged(event));
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
Group root = new Group();
|
152
|
+
|
153
|
+
root.set(menuBar,menuBar1);
|
154
|
+
|
155
|
+
root.getChildren().add(canvas);
|
156
|
+
|
157
|
+
stage.setScene(new Scene(root));
|
158
|
+
|
159
|
+
stage.show();
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
void mousePressed(MouseEvent event) {
|
168
|
+
|
169
|
+
g.moveTo(event.getX(), event.getY());
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
void mouseDragged(MouseEvent event) {
|
176
|
+
|
177
|
+
g.lineTo(event.getX(), event.getY());
|
178
|
+
|
179
|
+
g.stroke();
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
public static void main(String[] args) {
|
186
|
+
|
187
|
+
launch();
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|