質問編集履歴
3
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -340,8 +340,6 @@
|
|
340
340
|
|
341
341
|
|
342
342
|
|
343
|
-
//my-style.css
|
344
|
-
|
345
343
|
/* Styling the filled track */
|
346
344
|
|
347
345
|
.jfx-slider > .colored-track {
|
2
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -318,7 +318,7 @@
|
|
318
318
|
|
319
319
|
|
320
320
|
|
321
|
-
|
321
|
+
// my-style.css
|
322
322
|
|
323
323
|
/* Styling the slider track */
|
324
324
|
|
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,312 @@
|
|
14
14
|
|
15
15
|
Main.javaに直接設定する方法がありましたら、そちらもお願いいたします。
|
16
16
|
|
17
|
+
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
//Main.java
|
24
|
+
|
25
|
+
package application;
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
import javafx.application.Application;
|
30
|
+
|
31
|
+
import javafx.scene.Scene;
|
32
|
+
|
33
|
+
import javafx.scene.canvas.Canvas;
|
34
|
+
|
35
|
+
import javafx.scene.canvas.GraphicsContext;
|
36
|
+
|
37
|
+
import javafx.scene.control.Label;
|
38
|
+
|
39
|
+
import javafx.scene.control.Menu;
|
40
|
+
|
41
|
+
import javafx.scene.control.MenuBar;
|
42
|
+
|
43
|
+
import javafx.scene.control.MenuItem;
|
44
|
+
|
45
|
+
import javafx.scene.control.Slider;
|
46
|
+
|
47
|
+
import javafx.scene.layout.BorderPane;
|
48
|
+
|
49
|
+
import javafx.scene.layout.VBox;
|
50
|
+
|
51
|
+
import javafx.scene.paint.Color;
|
52
|
+
|
53
|
+
import javafx.stage.Stage;
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
public class RGBColor extends Application {
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Slider sliderR = new Slider(0, 255, 128);
|
62
|
+
|
63
|
+
Slider sliderG = new Slider(0, 255, 128);
|
64
|
+
|
65
|
+
Slider sliderB = new Slider(0, 255, 128);
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
Canvas canvas = new Canvas(600,80);
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
@Override
|
74
|
+
|
75
|
+
public void start(Stage stage) throws Exception {
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
stage.setTitle("RGBColor");
|
80
|
+
|
81
|
+
stage.setWidth(400);
|
82
|
+
|
83
|
+
stage.setHeight(280);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
MenuBar menuBar = new MenuBar();
|
88
|
+
|
89
|
+
menuBar.setUseSystemMenuBar(true);
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
Menu fileMenu = new Menu("File");
|
96
|
+
|
97
|
+
MenuItem mnuExit = new MenuItem("Exit");
|
98
|
+
|
99
|
+
mnuExit.setOnAction(event -> System.exit(0));
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
fileMenu.getItems().addAll(mnuExit);
|
104
|
+
|
105
|
+
menuBar.getMenus().add(fileMenu);
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
// Redラベルとスライダー
|
110
|
+
|
111
|
+
Label lblR = new Label(" Red:");
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
lblR.setTextFill(Color.rgb(255, 0, 0));
|
116
|
+
|
117
|
+
// Label label = new Label("LABEL");
|
118
|
+
|
119
|
+
// label.setFont(Font.font("Verdana", FontWeight.BOLD, 32));
|
120
|
+
|
121
|
+
// label.setTextAlignment(TextAlignment.CENTER);
|
122
|
+
|
123
|
+
// label.setText("NEW LABEL");
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
sliderR.setMaxWidth(380);
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
sliderR.getStylesheets().add("my-style.css");
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
sliderR.setShowTickMarks(true);
|
136
|
+
|
137
|
+
// 値がfalseだと、区切り線がなくなります。
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
sliderR.setShowTickLabels(true);
|
142
|
+
|
143
|
+
// 値がfalseだと、数字がなくなります。
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
sliderR.setMajorTickUnit(64.0);
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
sliderR.setBlockIncrement(1.0);
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
sliderR.setOnKeyPressed(event -> updateColor());
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
sliderR.setOnMouseMoved(event -> updateColor());
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
// Greenラベルとスライダー
|
164
|
+
|
165
|
+
Label lblG = new Label(" Green:");
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
lblG.setTextFill(Color.rgb(0, 255, 0));
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
sliderG.setMaxWidth(380);
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
sliderG.setShowTickMarks(true);
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
sliderG.setShowTickLabels(true);
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
sliderG.setMajorTickUnit(64.0);
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
sliderG.setBlockIncrement(1.0);
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
sliderG.setOnKeyPressed(event -> updateColor());
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
sliderG.setOnMouseMoved(event -> updateColor());
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
// Blueラベルとスライダー
|
202
|
+
|
203
|
+
Label lblB = new Label(" Blue:");
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
lblB.setTextFill(Color.rgb(0, 0, 255));
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
sliderB.setMaxWidth(380);
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
sliderB.setShowTickMarks(true);
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
sliderB.setShowTickLabels(true);
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
sliderB.setMajorTickUnit(64.0);
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
sliderB.setBlockIncrement(1.0);
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
sliderB.setOnKeyPressed(event -> updateColor());
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
sliderB.setOnMouseMoved(event -> updateColor());
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
VBox panel = new VBox();
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
panel.getChildren().addAll(lblR, sliderR, lblG, sliderG,lblB, sliderB);
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
BorderPane root = new BorderPane();
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
root.setStyle("-fx-background-color: yellow");
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
root.setTop(menuBar);
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
root.setCenter(panel);
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
updateColor();
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
stage.setScene(new Scene(root));
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
stage.show();
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
void updateColor(){
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
Color col = Color.rgb(
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
(int)sliderR.getValue(),
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
(int)sliderG.getValue(),
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
(int)sliderB.getValue() );
|
294
|
+
|
295
|
+
GraphicsContext gc = canvas.getGraphicsContext2D();
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
gc.setFill(col);
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
gc.fillRect(0,0,660,80);
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
public static void main(String[] args) {
|
312
|
+
|
313
|
+
launch(args);
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
17
323
|
/* Styling the slider track */
|
18
324
|
|
19
325
|
.jfx-slider > .track {
|
@@ -34,6 +340,8 @@
|
|
34
340
|
|
35
341
|
|
36
342
|
|
343
|
+
//my-style.css
|
344
|
+
|
37
345
|
/* Styling the filled track */
|
38
346
|
|
39
347
|
.jfx-slider > .colored-track {
|
@@ -66,634 +374,16 @@
|
|
66
374
|
|
67
375
|
|
68
376
|
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
69
389
|
```
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
//Main.java
|
74
|
-
|
75
|
-
package application;
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
import javafx.application.Application;
|
80
|
-
|
81
|
-
import javafx.scene.Scene;
|
82
|
-
|
83
|
-
import javafx.scene.canvas.Canvas;
|
84
|
-
|
85
|
-
import javafx.scene.canvas.GraphicsContext;
|
86
|
-
|
87
|
-
import javafx.scene.control.Label;
|
88
|
-
|
89
|
-
import javafx.scene.control.Menu;
|
90
|
-
|
91
|
-
import javafx.scene.control.MenuBar;
|
92
|
-
|
93
|
-
import javafx.scene.control.MenuItem;
|
94
|
-
|
95
|
-
import javafx.scene.control.Slider;
|
96
|
-
|
97
|
-
import javafx.scene.layout.BorderPane;
|
98
|
-
|
99
|
-
import javafx.scene.layout.VBox;
|
100
|
-
|
101
|
-
import javafx.scene.paint.Color;
|
102
|
-
|
103
|
-
import javafx.stage.Stage;
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
public class RGBColor extends Application {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
Slider sliderR = new Slider(0, 255, 128);
|
112
|
-
|
113
|
-
Slider sliderG = new Slider(0, 255, 128);
|
114
|
-
|
115
|
-
Slider sliderB = new Slider(0, 255, 128);
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
Canvas canvas = new Canvas(600,80);
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
@Override
|
124
|
-
|
125
|
-
public void start(Stage stage) throws Exception {
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
stage.setTitle("RGBColor");
|
130
|
-
|
131
|
-
stage.setWidth(400);
|
132
|
-
|
133
|
-
stage.setHeight(280);
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
MenuBar menuBar = new MenuBar();
|
138
|
-
|
139
|
-
menuBar.setUseSystemMenuBar(true);
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
Menu fileMenu = new Menu("File");
|
146
|
-
|
147
|
-
MenuItem mnuExit = new MenuItem("Exit");
|
148
|
-
|
149
|
-
mnuExit.setOnAction(event -> System.exit(0));
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
fileMenu.getItems().addAll(mnuExit);
|
154
|
-
|
155
|
-
menuBar.getMenus().add(fileMenu);
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
// Redラベルとスライダー
|
160
|
-
|
161
|
-
Label lblR = new Label(" Red:");
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
lblR.setTextFill(Color.rgb(255, 0, 0));
|
166
|
-
|
167
|
-
// Label label = new Label("LABEL");
|
168
|
-
|
169
|
-
// label.setFont(Font.font("Verdana", FontWeight.BOLD, 32));
|
170
|
-
|
171
|
-
// label.setTextAlignment(TextAlignment.CENTER);
|
172
|
-
|
173
|
-
// label.setText("NEW LABEL");
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
sliderR.setMaxWidth(380);
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
sliderR.getStylesheets().add("my-style.css");
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
sliderR.setShowTickMarks(true);
|
186
|
-
|
187
|
-
// 値がfalseだと、区切り線がなくなります。
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
sliderR.setShowTickLabels(true);
|
192
|
-
|
193
|
-
// 値がfalseだと、数字がなくなります。
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
sliderR.setMajorTickUnit(64.0);
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
sliderR.setBlockIncrement(1.0);
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
sliderR.setOnKeyPressed(event -> updateColor());
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
sliderR.setOnMouseMoved(event -> updateColor());
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
// Greenラベルとスライダー
|
214
|
-
|
215
|
-
Label lblG = new Label(" Green:");
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
lblG.setTextFill(Color.rgb(0, 255, 0));
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
sliderG.setMaxWidth(380);
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
sliderG.setShowTickMarks(true);
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
sliderG.setShowTickLabels(true);
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
sliderG.setMajorTickUnit(64.0);
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
sliderG.setBlockIncrement(1.0);
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
sliderG.setOnKeyPressed(event -> updateColor());
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
sliderG.setOnMouseMoved(event -> updateColor());
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
// Blueラベルとスライダー
|
252
|
-
|
253
|
-
Label lblB = new Label(" Blue:");
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
lblB.setTextFill(Color.rgb(0, 0, 255));
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
sliderB.setMaxWidth(380);
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
sliderB.setShowTickMarks(true);
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
sliderB.setShowTickLabels(true);
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
sliderB.setMajorTickUnit(64.0);
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
sliderB.setBlockIncrement(1.0);
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
sliderB.setOnKeyPressed(event -> updateColor());
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
sliderB.setOnMouseMoved(event -> updateColor());
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
VBox panel = new VBox();
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
panel.getChildren().addAll(lblR, sliderR, lblG, sliderG,lblB, sliderB);
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
BorderPane root = new BorderPane();
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
root.setStyle("-fx-background-color: yellow");
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
root.setTop(menuBar);
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
root.setCenter(panel);
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
updateColor();
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
stage.setScene(new Scene(root));
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
stage.show();
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
void updateColor(){
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
Color col = Color.rgb(
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
(int)sliderR.getValue(),
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
(int)sliderG.getValue(),
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
(int)sliderB.getValue() );
|
344
|
-
|
345
|
-
GraphicsContext gc = canvas.getGraphicsContext2D();
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
gc.setFill(col);
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
gc.fillRect(0,0,660,80);
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
public static void main(String[] args) {
|
362
|
-
|
363
|
-
launch(args);
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
}
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
```ここに言語を入力
|
388
|
-
|
389
|
-
package application;
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
import javafx.application.Application;
|
394
|
-
|
395
|
-
import javafx.scene.Scene;
|
396
|
-
|
397
|
-
import javafx.scene.canvas.Canvas;
|
398
|
-
|
399
|
-
import javafx.scene.canvas.GraphicsContext;
|
400
|
-
|
401
|
-
import javafx.scene.control.Label;
|
402
|
-
|
403
|
-
import javafx.scene.control.Menu;
|
404
|
-
|
405
|
-
import javafx.scene.control.MenuBar;
|
406
|
-
|
407
|
-
import javafx.scene.control.MenuItem;
|
408
|
-
|
409
|
-
import javafx.scene.control.Slider;
|
410
|
-
|
411
|
-
import javafx.scene.layout.BorderPane;
|
412
|
-
|
413
|
-
import javafx.scene.layout.VBox;
|
414
|
-
|
415
|
-
import javafx.scene.paint.Color;
|
416
|
-
|
417
|
-
import javafx.stage.Stage;
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
public class RGBColor extends Application {
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
Slider sliderR = new Slider(0, 255, 128);
|
426
|
-
|
427
|
-
Slider sliderG = new Slider(0, 255, 128);
|
428
|
-
|
429
|
-
Slider sliderB = new Slider(0, 255, 128);
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
Canvas canvas = new Canvas(600,80);
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
@Override
|
438
|
-
|
439
|
-
public void start(Stage stage) throws Exception {
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
stage.setTitle("RGBColor");
|
444
|
-
|
445
|
-
stage.setWidth(400);
|
446
|
-
|
447
|
-
stage.setHeight(280);
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
MenuBar menuBar = new MenuBar();
|
452
|
-
|
453
|
-
menuBar.setUseSystemMenuBar(true);
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
Menu fileMenu = new Menu("File");
|
460
|
-
|
461
|
-
MenuItem mnuExit = new MenuItem("Exit");
|
462
|
-
|
463
|
-
mnuExit.setOnAction(event -> System.exit(0));
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
fileMenu.getItems().addAll(mnuExit);
|
468
|
-
|
469
|
-
menuBar.getMenus().add(fileMenu);
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
// Redラベルとスライダー
|
474
|
-
|
475
|
-
Label lblR = new Label(" Red:");
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
lblR.setTextFill(Color.rgb(255, 0, 0));
|
480
|
-
|
481
|
-
// Label label = new Label("LABEL");
|
482
|
-
|
483
|
-
// label.setFont(Font.font("Verdana", FontWeight.BOLD, 32));
|
484
|
-
|
485
|
-
// label.setTextAlignment(TextAlignment.CENTER);
|
486
|
-
|
487
|
-
// label.setText("NEW LABEL");
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
sliderR.setMaxWidth(380);
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
sliderR.getStylesheets().add("my-style.css");
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
sliderR.setShowTickMarks(true);
|
500
|
-
|
501
|
-
// 値がfalseだと、区切り線がなくなります。
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
sliderR.setShowTickLabels(true);
|
506
|
-
|
507
|
-
// 値がfalseだと、数字がなくなります。
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
sliderR.setMajorTickUnit(64.0);
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
sliderR.setBlockIncrement(1.0);
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
sliderR.setOnKeyPressed(event -> updateColor());
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
sliderR.setOnMouseMoved(event -> updateColor());
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
// Greenラベルとスライダー
|
528
|
-
|
529
|
-
Label lblG = new Label(" Green:");
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
lblG.setTextFill(Color.rgb(0, 255, 0));
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
sliderG.setMaxWidth(380);
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
sliderG.setShowTickMarks(true);
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
sliderG.setShowTickLabels(true);
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
sliderG.setMajorTickUnit(64.0);
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
sliderG.setBlockIncrement(1.0);
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
sliderG.setOnKeyPressed(event -> updateColor());
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
sliderG.setOnMouseMoved(event -> updateColor());
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
// Blueラベルとスライダー
|
566
|
-
|
567
|
-
Label lblB = new Label(" Blue:");
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
lblB.setTextFill(Color.rgb(0, 0, 255));
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
sliderB.setMaxWidth(380);
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
sliderB.setShowTickMarks(true);
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
sliderB.setShowTickLabels(true);
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
sliderB.setMajorTickUnit(64.0);
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
sliderB.setBlockIncrement(1.0);
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
sliderB.setOnKeyPressed(event -> updateColor());
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
sliderB.setOnMouseMoved(event -> updateColor());
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
VBox panel = new VBox();
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
panel.getChildren().addAll(lblR, sliderR, lblG, sliderG,lblB, sliderB);
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
BorderPane root = new BorderPane();
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
root.setStyle("-fx-background-color: yellow");
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
root.setTop(menuBar);
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
root.setCenter(panel);
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
updateColor();
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
stage.setScene(new Scene(root));
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
stage.show();
|
636
|
-
|
637
|
-
}
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
void updateColor(){
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
Color col = Color.rgb(
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
(int)sliderR.getValue(),
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
(int)sliderG.getValue(),
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
(int)sliderB.getValue() );
|
658
|
-
|
659
|
-
GraphicsContext gc = canvas.getGraphicsContext2D();
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
gc.setFill(col);
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
gc.fillRect(0,0,660,80);
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
}
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
public static void main(String[] args) {
|
676
|
-
|
677
|
-
launch(args);
|
678
|
-
|
679
|
-
}
|
680
|
-
|
681
|
-
}
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
```
|