質問編集履歴
4
文章の読みやすさ
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,11 +202,11 @@
|
|
202
202
|
|
203
203
|
}
|
204
204
|
|
205
|
+
```
|
206
|
+
|
205
207
|
```Java
|
206
208
|
|
207
|
-
コード
|
208
|
-
|
209
|
-
|
209
|
+
コードpackage gazou;
|
210
210
|
|
211
211
|
|
212
212
|
|
@@ -332,6 +332,8 @@
|
|
332
332
|
|
333
333
|
|
334
334
|
|
335
|
+
```
|
336
|
+
|
335
337
|
```java
|
336
338
|
|
337
339
|
package gazou;
|
@@ -470,7 +472,9 @@
|
|
470
472
|
|
471
473
|
}
|
472
474
|
|
475
|
+
```
|
476
|
+
|
473
|
-
```
|
477
|
+
```Java
|
474
478
|
|
475
479
|
コードpackage gazou;
|
476
480
|
|
3
イメージ追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
![実行結果](0f8f72b53a8f8125ecdcdcd4ae803113.png)
|
2
|
+
|
1
3
|
```JAVA
|
2
4
|
|
3
5
|
コードpackage gazou;
|
@@ -200,308 +202,310 @@
|
|
200
202
|
|
201
203
|
}
|
202
204
|
|
203
|
-
```J
|
205
|
+
```Java
|
206
|
+
|
207
|
+
コード
|
208
|
+
|
209
|
+
```package gazou;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
import java.awt.Color;
|
214
|
+
|
215
|
+
import java.awt.event.ActionEvent;
|
216
|
+
|
217
|
+
import java.awt.event.ActionListener;
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
import javax.swing.JButton;
|
222
|
+
|
223
|
+
import javax.swing.JLabel;
|
224
|
+
|
225
|
+
import javax.swing.JPanel;
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
public class Taitoru0 extends JPanel {
|
234
|
+
|
235
|
+
JButton btn,btn2,btn3;
|
236
|
+
|
237
|
+
JLabel paneltitle;
|
238
|
+
|
239
|
+
MainFrame mf;
|
240
|
+
|
241
|
+
String str;
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
public Taitoru0(MainFrame m,String s){
|
246
|
+
|
247
|
+
mf = m;
|
248
|
+
|
249
|
+
str = s;
|
250
|
+
|
251
|
+
this.setName("mp");
|
252
|
+
|
253
|
+
this.setLayout(null);
|
254
|
+
|
255
|
+
this.setSize(500, 400);
|
256
|
+
|
257
|
+
paneltitle = new JLabel("これは"
|
258
|
+
|
259
|
+
+getClass().getCanonicalName()+"タイトルクラスのパネルです");
|
260
|
+
|
261
|
+
paneltitle.setBounds(0, 5, 400, 40);
|
262
|
+
|
263
|
+
this.add(paneltitle);
|
264
|
+
|
265
|
+
//
|
266
|
+
|
267
|
+
btn = new JButton("モード選択に移動");
|
268
|
+
|
269
|
+
btn.setBounds(20, 50, 150, 40);
|
270
|
+
|
271
|
+
btn.addActionListener(new ActionListener(){
|
272
|
+
|
273
|
+
public void actionPerformed(ActionEvent e){
|
274
|
+
|
275
|
+
pc();
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
});
|
280
|
+
|
281
|
+
this.add(btn);
|
282
|
+
|
283
|
+
/*
|
284
|
+
|
285
|
+
btn2 = new JButton("SubPanel2に移動");
|
286
|
+
|
287
|
+
btn2.setBounds(20, 100, 150, 40);
|
288
|
+
|
289
|
+
btn2.addActionListener(new ActionListener(){
|
290
|
+
|
291
|
+
public void actionPerformed(ActionEvent e){
|
292
|
+
|
293
|
+
pc(mf.PanelNames[2]);
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
});
|
298
|
+
|
299
|
+
this.add(btn2);
|
300
|
+
|
301
|
+
btn3 = new JButton("SubPanel3に移動");
|
302
|
+
|
303
|
+
btn3.setBounds(200, 100, 150, 40);
|
304
|
+
|
305
|
+
btn3.addActionListener(new ActionListener(){
|
306
|
+
|
307
|
+
public void actionPerformed(ActionEvent e){
|
308
|
+
|
309
|
+
pc(mf.PanelNames[3]);
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
});
|
314
|
+
|
315
|
+
this.add(btn3);*/
|
316
|
+
|
317
|
+
Float f = (float) Math.random();
|
318
|
+
|
319
|
+
this.setBackground(Color.getHSBColor(f, 0.9f, 0.9f));
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
public void pc(){
|
326
|
+
|
327
|
+
mf.PanelChange((JPanel)this,mf.PanelNames[1]);
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
```java
|
336
|
+
|
337
|
+
package gazou;
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
import java.awt.event.ActionEvent;
|
342
|
+
|
343
|
+
import java.awt.event.ActionListener;
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
import javax.swing.JButton;
|
348
|
+
|
349
|
+
import javax.swing.JPanel;
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
public class Mode1 extends Cara2 {
|
356
|
+
|
357
|
+
JButton btn1,btn2;
|
358
|
+
|
359
|
+
public Mode1(MainFrame m,String s){
|
360
|
+
|
361
|
+
super(m,s);
|
362
|
+
|
363
|
+
mf = m;
|
364
|
+
|
365
|
+
str = s;
|
366
|
+
|
367
|
+
btn1 = new JButton("シングルプレイ");
|
368
|
+
|
369
|
+
btn1.setBounds(20, 50, 150, 40);
|
370
|
+
|
371
|
+
btn1.addActionListener(new ActionListener(){
|
372
|
+
|
373
|
+
public void actionPerformed(ActionEvent e){
|
374
|
+
|
375
|
+
pc();
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
});
|
380
|
+
|
381
|
+
this.add(btn1);
|
382
|
+
|
383
|
+
//
|
384
|
+
|
385
|
+
btn2 = new JButton("マルチプレイ");
|
386
|
+
|
387
|
+
btn2.setBounds(20, 100, 150, 40);
|
388
|
+
|
389
|
+
btn2.addActionListener(new ActionListener(){
|
390
|
+
|
391
|
+
public void actionPerformed(ActionEvent e){
|
392
|
+
|
393
|
+
pc();
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
});
|
398
|
+
|
399
|
+
this.add(btn2);
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
@Override
|
410
|
+
|
411
|
+
public void pc(){
|
412
|
+
|
413
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[2]);
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
}
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
```
|
426
|
+
|
427
|
+
```![実行するとこうなります](2000db0743dbb5a18bd436533a48fe8e.png)ボタンに画像を貼り付ける方法がわからない
|
428
|
+
|
429
|
+
```Java
|
430
|
+
|
431
|
+
コードimport javax.swing.ImageIcon;
|
432
|
+
|
433
|
+
import javax.swing.JButton;
|
434
|
+
|
435
|
+
import javax.swing.JPanel;
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
public class Cara2 extends Loading3 {
|
440
|
+
|
441
|
+
public Cara2(MainFrame m,String s){
|
442
|
+
|
443
|
+
super(m,s);
|
444
|
+
|
445
|
+
JPanel p = new JPanel();
|
446
|
+
|
447
|
+
ImageIcon icon1 = new ImageIcon("Z:/Java/gazou1/bin/gazou1/ca-bi.png");
|
448
|
+
|
449
|
+
JButton button1 = new JButton(icon1);
|
450
|
+
|
451
|
+
button1.setIcon(icon1);
|
452
|
+
|
453
|
+
button1.setBounds(20, 50, 150, 40);
|
454
|
+
|
455
|
+
button1.setText("カービィ ");
|
456
|
+
|
457
|
+
p.add(button1);
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
@Override
|
464
|
+
|
465
|
+
public void pc(){
|
466
|
+
|
467
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[3]);
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
```java
|
204
474
|
|
205
475
|
コードpackage gazou;
|
206
476
|
|
207
477
|
|
208
478
|
|
209
|
-
import java.awt.Color;
|
210
|
-
|
211
|
-
import java.awt.event.ActionEvent;
|
212
|
-
|
213
|
-
import java.awt.event.ActionListener;
|
214
|
-
|
215
|
-
|
216
|
-
|
217
479
|
import javax.swing.JButton;
|
218
480
|
|
219
|
-
import javax.swing.JLabel;
|
220
|
-
|
221
481
|
import javax.swing.JPanel;
|
222
482
|
|
223
483
|
|
224
484
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
public class
|
485
|
+
public class Loading3 extends Stage4 {
|
230
|
-
|
486
|
+
|
231
|
-
|
487
|
+
JButton btn1,btn2;
|
232
|
-
|
233
|
-
|
488
|
+
|
234
|
-
|
235
|
-
MainFrame mf;
|
236
|
-
|
237
|
-
String str;
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
public
|
489
|
+
public Loading3(MainFrame m,String s){
|
242
|
-
|
243
|
-
|
490
|
+
|
244
|
-
|
245
|
-
s
|
491
|
+
super(m,s);
|
246
|
-
|
492
|
+
|
247
|
-
t
|
493
|
+
btn.setText("0000000000");
|
248
|
-
|
249
|
-
|
494
|
+
|
250
|
-
|
251
|
-
this.setSize(500, 400);
|
252
|
-
|
253
|
-
paneltitle = new JLabel("これは"
|
254
|
-
|
255
|
-
+getClass().getCanonicalName()+"タイトルクラスのパネルです");
|
256
|
-
|
257
|
-
paneltitle.setBounds(0, 5, 400, 40);
|
258
|
-
|
259
|
-
this.add(paneltitle);
|
260
|
-
|
261
|
-
//
|
262
|
-
|
263
|
-
btn = new JButton("モード選択に移動");
|
264
|
-
|
265
|
-
btn.setBounds(20, 50, 150, 40);
|
266
|
-
|
267
|
-
btn.addActionListener(new ActionListener(){
|
268
|
-
|
269
|
-
public void actionPerformed(ActionEvent e){
|
270
|
-
|
271
|
-
pc();
|
272
|
-
|
273
|
-
|
495
|
+
}
|
274
|
-
|
275
|
-
|
496
|
+
|
276
|
-
|
277
|
-
this.add(btn);
|
278
|
-
|
279
|
-
|
497
|
+
@Override
|
280
|
-
|
281
|
-
btn2 = new JButton("SubPanel2に移動");
|
282
|
-
|
283
|
-
btn2.setBounds(20, 100, 150, 40);
|
284
|
-
|
285
|
-
btn2.addActionListener(new ActionListener(){
|
286
|
-
|
287
|
-
public void actionPerformed(ActionEvent e){
|
288
|
-
|
289
|
-
pc(mf.PanelNames[2]);
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
});
|
294
|
-
|
295
|
-
this.add(btn2);
|
296
|
-
|
297
|
-
btn3 = new JButton("SubPanel3に移動");
|
298
|
-
|
299
|
-
btn3.setBounds(200, 100, 150, 40);
|
300
|
-
|
301
|
-
btn3.addActionListener(new ActionListener(){
|
302
|
-
|
303
|
-
public void actionPerformed(ActionEvent e){
|
304
|
-
|
305
|
-
pc(mf.PanelNames[3]);
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
});
|
310
|
-
|
311
|
-
this.add(btn3);*/
|
312
|
-
|
313
|
-
Float f = (float) Math.random();
|
314
|
-
|
315
|
-
this.setBackground(Color.getHSBColor(f, 0.9f, 0.9f));
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
}
|
320
498
|
|
321
499
|
public void pc(){
|
322
500
|
|
323
|
-
mf.PanelChange((JPanel)this,mf.PanelNames[1]);
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
}```java
|
328
|
-
|
329
|
-
コード
|
330
|
-
|
331
|
-
```java
|
332
|
-
|
333
|
-
package gazou;
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
import java.awt.event.ActionEvent;
|
338
|
-
|
339
|
-
import java.awt.event.ActionListener;
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
import javax.swing.JButton;
|
344
|
-
|
345
|
-
import javax.swing.JPanel;
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
public class Mode1 extends Cara2 {
|
352
|
-
|
353
|
-
JButton btn1,btn2;
|
354
|
-
|
355
|
-
public Mode1(MainFrame m,String s){
|
356
|
-
|
357
|
-
super(m,s);
|
358
|
-
|
359
|
-
mf = m;
|
360
|
-
|
361
|
-
str = s;
|
362
|
-
|
363
|
-
btn1 = new JButton("シングルプレイ");
|
364
|
-
|
365
|
-
btn1.setBounds(20, 50, 150, 40);
|
366
|
-
|
367
|
-
btn1.addActionListener(new ActionListener(){
|
368
|
-
|
369
|
-
public void actionPerformed(ActionEvent e){
|
370
|
-
|
371
|
-
pc();
|
372
|
-
|
373
|
-
}
|
374
|
-
|
375
|
-
});
|
376
|
-
|
377
|
-
this.add(btn1);
|
378
|
-
|
379
|
-
//
|
380
|
-
|
381
|
-
btn2 = new JButton("マルチプレイ");
|
382
|
-
|
383
|
-
btn2.setBounds(20, 100, 150, 40);
|
384
|
-
|
385
|
-
btn2.addActionListener(new ActionListener(){
|
386
|
-
|
387
|
-
public void actionPerformed(ActionEvent e){
|
388
|
-
|
389
|
-
pc();
|
390
|
-
|
391
|
-
}
|
392
|
-
|
393
|
-
});
|
394
|
-
|
395
|
-
this.add(btn2);
|
396
|
-
|
397
|
-
}
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
@Override
|
406
|
-
|
407
|
-
public void pc(){
|
408
|
-
|
409
|
-
mf.PanelChange((JPanel)this, mf.PanelNames[
|
501
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[4]);
|
410
502
|
|
411
503
|
}
|
412
504
|
|
413
505
|
}
|
414
506
|
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
507
|
```
|
422
508
|
|
423
|
-
```![実行するとこうなります](2000db0743dbb5a18bd436533a48fe8e.png)ボタンに画像を貼り付ける方法がわからない
|
424
|
-
|
425
|
-
```Java
|
426
|
-
|
427
|
-
コードimport javax.swing.ImageIcon;
|
428
|
-
|
429
|
-
import javax.swing.JButton;
|
430
|
-
|
431
|
-
import javax.swing.JPanel;
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
public class Cara2 extends Loading3 {
|
436
|
-
|
437
|
-
public Cara2(MainFrame m,String s){
|
438
|
-
|
439
|
-
super(m,s);
|
440
|
-
|
441
|
-
JPanel p = new JPanel();
|
442
|
-
|
443
|
-
ImageIcon icon1 = new ImageIcon("Z:/Java/gazou1/bin/gazou1/ca-bi.png");
|
444
|
-
|
445
|
-
JButton button1 = new JButton(icon1);
|
446
|
-
|
447
|
-
button1.setIcon(icon1);
|
448
|
-
|
449
|
-
button1.setBounds(20, 50, 150, 40);
|
450
|
-
|
451
|
-
button1.setText("カービィ ");
|
452
|
-
|
453
|
-
p.add(button1);
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
}
|
458
|
-
|
459
|
-
@Override
|
460
|
-
|
461
|
-
public void pc(){
|
462
|
-
|
463
|
-
mf.PanelChange((JPanel)this, mf.PanelNames[3]);
|
464
|
-
|
465
|
-
}
|
466
|
-
|
467
|
-
}
|
468
|
-
|
469
|
-
```java
|
470
|
-
|
471
|
-
コードpackage gazou;
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
import javax.swing.JButton;
|
476
|
-
|
477
|
-
import javax.swing.JPanel;
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
public class Loading3 extends Stage4 {
|
482
|
-
|
483
|
-
JButton btn1,btn2;
|
484
|
-
|
485
|
-
public Loading3(MainFrame m,String s){
|
486
|
-
|
487
|
-
super(m,s);
|
488
|
-
|
489
|
-
btn.setText("0000000000");
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
@Override
|
494
|
-
|
495
|
-
public void pc(){
|
496
|
-
|
497
|
-
mf.PanelChange((JPanel)this, mf.PanelNames[4]);
|
498
|
-
|
499
|
-
}
|
500
|
-
|
501
|
-
}
|
502
|
-
|
503
|
-
```
|
504
|
-
|
505
509
|
|
506
510
|
|
507
511
|
```[引用サイト](https://www.javadrive.jp/tutorial/jbutton/index8.html)
|
2
Mainframe Taitoru0 Mode1 Cara2 Loading3 の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,426 @@
|
|
1
|
+
```JAVA
|
2
|
+
|
3
|
+
コードpackage gazou;
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
import javax.swing.JFrame;
|
8
|
+
|
9
|
+
import javax.swing.JPanel;
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
public class MainFrame extends JFrame{
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
public String[] PanelNames = {"mp","1","2","3","4","5","6","7","8","9"};
|
18
|
+
|
19
|
+
Taitoru0 mp = new Taitoru0(this,PanelNames[0]);
|
20
|
+
|
21
|
+
Mode1 sp = new Mode1(this,PanelNames[1]);
|
22
|
+
|
23
|
+
Cara2 sp2 = new Cara2(this,PanelNames[2]);
|
24
|
+
|
25
|
+
Loading3 sp3 = new Loading3(this,PanelNames[3]);
|
26
|
+
|
27
|
+
Stage4 sp4 = new Stage4(this,PanelNames[4]);
|
28
|
+
|
29
|
+
VS5 sp5 = new VS5(this,PanelNames[5]);
|
30
|
+
|
31
|
+
Batoru6 sp6 = new Batoru6(this,PanelNames[6]);
|
32
|
+
|
33
|
+
Result7 sp7 = new Result7(this,PanelNames[7]);
|
34
|
+
|
35
|
+
// bunki8 sp8 = new bunki8(this,PanelNames[8]);
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
public MainFrame(){
|
44
|
+
|
45
|
+
this.add(mp);mp.setVisible(true);
|
46
|
+
|
47
|
+
this.add(sp);sp.setVisible(false);
|
48
|
+
|
49
|
+
this.add(sp2);sp2.setVisible(false);
|
50
|
+
|
51
|
+
this.add(sp3);sp3.setVisible(false);
|
52
|
+
|
53
|
+
this.add(sp4);sp4.setVisible(false);
|
54
|
+
|
55
|
+
this.add(sp5);sp5.setVisible(false);
|
56
|
+
|
57
|
+
this.add(sp6);sp6.setVisible(false);
|
58
|
+
|
59
|
+
this.add(sp7);sp7.setVisible(false);
|
60
|
+
|
61
|
+
// this.add(sp8);sp8.setVisible(false);
|
62
|
+
|
63
|
+
// this.add(sp9);sp9.setVisible(false);
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
this.setBounds(100, 100, 800, 600);
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
public static void main(String[] args) {
|
72
|
+
|
73
|
+
MainFrame mf = new MainFrame();
|
74
|
+
|
75
|
+
mf.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
76
|
+
|
77
|
+
mf.setTitle("ACE DREAM MATCH");//タイトルバーの名前
|
78
|
+
|
79
|
+
mf.setVisible(true);
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
public void PanelChange(JPanel jp, String str){
|
84
|
+
|
85
|
+
System.out.println(jp.getName());
|
86
|
+
|
87
|
+
String name = jp.getName();
|
88
|
+
|
89
|
+
if(name==PanelNames[0]){
|
90
|
+
|
91
|
+
mp = (Taitoru0)jp;
|
92
|
+
|
93
|
+
mp.setVisible(false);
|
94
|
+
|
95
|
+
}else if(name==PanelNames[1]){
|
96
|
+
|
97
|
+
sp = (Mode1)jp;
|
98
|
+
|
99
|
+
sp.setVisible(false);
|
100
|
+
|
101
|
+
}else if(name==PanelNames[2]){
|
102
|
+
|
103
|
+
sp2 = (Cara2)jp;
|
104
|
+
|
105
|
+
sp2.setVisible(false);
|
106
|
+
|
107
|
+
}else if(name==PanelNames[3]){
|
108
|
+
|
109
|
+
sp3 = (Loading3)jp;
|
110
|
+
|
111
|
+
sp3.setVisible(false);
|
112
|
+
|
113
|
+
}else if(name==PanelNames[4]){
|
114
|
+
|
115
|
+
sp4 = (Stage4)jp;
|
116
|
+
|
117
|
+
sp4.setVisible(false);
|
118
|
+
|
119
|
+
}else if(name==PanelNames[5]){
|
120
|
+
|
121
|
+
sp5 = (VS5)jp;
|
122
|
+
|
123
|
+
sp5.setVisible(false);
|
124
|
+
|
125
|
+
}else if(name==PanelNames[6]){
|
126
|
+
|
127
|
+
sp6 = (Batoru6)jp;
|
128
|
+
|
129
|
+
sp6.setVisible(false);
|
130
|
+
|
131
|
+
}else if(name==PanelNames[7]){
|
132
|
+
|
133
|
+
sp7 = (Result7)jp;
|
134
|
+
|
135
|
+
sp7.setVisible(false);
|
136
|
+
|
137
|
+
}//else if(name==PanelNames[8]){
|
138
|
+
|
139
|
+
// sp8 = (bunki8)jp;
|
140
|
+
|
141
|
+
// sp8.setVisible(false);
|
142
|
+
|
143
|
+
// }//else if(name==PanelNames[9]){
|
144
|
+
|
145
|
+
// sp9 = (Mode1_m9)jp;
|
146
|
+
|
147
|
+
// sp9.setVisible(false);
|
148
|
+
|
149
|
+
//}
|
150
|
+
|
151
|
+
if(str==PanelNames[0]){
|
152
|
+
|
153
|
+
mp.setVisible(true);
|
154
|
+
|
155
|
+
}else if(str==PanelNames[1]){
|
156
|
+
|
157
|
+
sp.setVisible(true);
|
158
|
+
|
159
|
+
}else if(str==PanelNames[2]){
|
160
|
+
|
161
|
+
sp2.setVisible(true);
|
162
|
+
|
163
|
+
}else if(str==PanelNames[3]){
|
164
|
+
|
165
|
+
sp3.setVisible(true);
|
166
|
+
|
167
|
+
}else if(str==PanelNames[4]){
|
168
|
+
|
169
|
+
sp4.setVisible(true);
|
170
|
+
|
171
|
+
}else if(str==PanelNames[5]){
|
172
|
+
|
173
|
+
sp5.setVisible(true);
|
174
|
+
|
175
|
+
}else if(str==PanelNames[6]){
|
176
|
+
|
177
|
+
sp6.setVisible(true);
|
178
|
+
|
179
|
+
}else if(str==PanelNames[7]){
|
180
|
+
|
181
|
+
sp7.setVisible(true);
|
182
|
+
|
183
|
+
}/*else if(str==PanelNames[8]){
|
184
|
+
|
185
|
+
sp8.setVisible(true);
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
//else if(str==PanelNames[9]){
|
190
|
+
|
191
|
+
// sp9.setVisible(true);
|
192
|
+
|
193
|
+
//}*/
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
```JAVA
|
204
|
+
|
205
|
+
コードpackage gazou;
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
import java.awt.Color;
|
210
|
+
|
211
|
+
import java.awt.event.ActionEvent;
|
212
|
+
|
213
|
+
import java.awt.event.ActionListener;
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
import javax.swing.JButton;
|
218
|
+
|
219
|
+
import javax.swing.JLabel;
|
220
|
+
|
221
|
+
import javax.swing.JPanel;
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
public class Taitoru0 extends JPanel {
|
230
|
+
|
231
|
+
JButton btn,btn2,btn3;
|
232
|
+
|
233
|
+
JLabel paneltitle;
|
234
|
+
|
235
|
+
MainFrame mf;
|
236
|
+
|
237
|
+
String str;
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
public Taitoru0(MainFrame m,String s){
|
242
|
+
|
243
|
+
mf = m;
|
244
|
+
|
245
|
+
str = s;
|
246
|
+
|
247
|
+
this.setName("mp");
|
248
|
+
|
249
|
+
this.setLayout(null);
|
250
|
+
|
251
|
+
this.setSize(500, 400);
|
252
|
+
|
253
|
+
paneltitle = new JLabel("これは"
|
254
|
+
|
255
|
+
+getClass().getCanonicalName()+"タイトルクラスのパネルです");
|
256
|
+
|
257
|
+
paneltitle.setBounds(0, 5, 400, 40);
|
258
|
+
|
259
|
+
this.add(paneltitle);
|
260
|
+
|
261
|
+
//
|
262
|
+
|
263
|
+
btn = new JButton("モード選択に移動");
|
264
|
+
|
265
|
+
btn.setBounds(20, 50, 150, 40);
|
266
|
+
|
267
|
+
btn.addActionListener(new ActionListener(){
|
268
|
+
|
269
|
+
public void actionPerformed(ActionEvent e){
|
270
|
+
|
271
|
+
pc();
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
});
|
276
|
+
|
277
|
+
this.add(btn);
|
278
|
+
|
279
|
+
/*
|
280
|
+
|
281
|
+
btn2 = new JButton("SubPanel2に移動");
|
282
|
+
|
283
|
+
btn2.setBounds(20, 100, 150, 40);
|
284
|
+
|
285
|
+
btn2.addActionListener(new ActionListener(){
|
286
|
+
|
287
|
+
public void actionPerformed(ActionEvent e){
|
288
|
+
|
289
|
+
pc(mf.PanelNames[2]);
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
});
|
294
|
+
|
295
|
+
this.add(btn2);
|
296
|
+
|
297
|
+
btn3 = new JButton("SubPanel3に移動");
|
298
|
+
|
299
|
+
btn3.setBounds(200, 100, 150, 40);
|
300
|
+
|
301
|
+
btn3.addActionListener(new ActionListener(){
|
302
|
+
|
303
|
+
public void actionPerformed(ActionEvent e){
|
304
|
+
|
305
|
+
pc(mf.PanelNames[3]);
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
});
|
310
|
+
|
311
|
+
this.add(btn3);*/
|
312
|
+
|
313
|
+
Float f = (float) Math.random();
|
314
|
+
|
315
|
+
this.setBackground(Color.getHSBColor(f, 0.9f, 0.9f));
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
public void pc(){
|
322
|
+
|
323
|
+
mf.PanelChange((JPanel)this,mf.PanelNames[1]);
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
}```java
|
328
|
+
|
329
|
+
コード
|
330
|
+
|
331
|
+
```java
|
332
|
+
|
333
|
+
package gazou;
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
import java.awt.event.ActionEvent;
|
338
|
+
|
339
|
+
import java.awt.event.ActionListener;
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
import javax.swing.JButton;
|
344
|
+
|
345
|
+
import javax.swing.JPanel;
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
public class Mode1 extends Cara2 {
|
352
|
+
|
353
|
+
JButton btn1,btn2;
|
354
|
+
|
355
|
+
public Mode1(MainFrame m,String s){
|
356
|
+
|
357
|
+
super(m,s);
|
358
|
+
|
359
|
+
mf = m;
|
360
|
+
|
361
|
+
str = s;
|
362
|
+
|
363
|
+
btn1 = new JButton("シングルプレイ");
|
364
|
+
|
365
|
+
btn1.setBounds(20, 50, 150, 40);
|
366
|
+
|
367
|
+
btn1.addActionListener(new ActionListener(){
|
368
|
+
|
369
|
+
public void actionPerformed(ActionEvent e){
|
370
|
+
|
371
|
+
pc();
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
});
|
376
|
+
|
377
|
+
this.add(btn1);
|
378
|
+
|
379
|
+
//
|
380
|
+
|
381
|
+
btn2 = new JButton("マルチプレイ");
|
382
|
+
|
383
|
+
btn2.setBounds(20, 100, 150, 40);
|
384
|
+
|
385
|
+
btn2.addActionListener(new ActionListener(){
|
386
|
+
|
387
|
+
public void actionPerformed(ActionEvent e){
|
388
|
+
|
389
|
+
pc();
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
});
|
394
|
+
|
395
|
+
this.add(btn2);
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
@Override
|
406
|
+
|
407
|
+
public void pc(){
|
408
|
+
|
409
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[2]);
|
410
|
+
|
411
|
+
}
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
```
|
422
|
+
|
1
|
-
![実行するとこうなります](2000db0743dbb5a18bd436533a48fe8e.png)ボタンに画像を貼り付ける方法がわからない
|
423
|
+
```![実行するとこうなります](2000db0743dbb5a18bd436533a48fe8e.png)ボタンに画像を貼り付ける方法がわからない
|
2
424
|
|
3
425
|
```Java
|
4
426
|
|
@@ -44,7 +466,41 @@
|
|
44
466
|
|
45
467
|
}
|
46
468
|
|
47
|
-
|
469
|
+
```java
|
470
|
+
|
471
|
+
コードpackage gazou;
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
import javax.swing.JButton;
|
476
|
+
|
477
|
+
import javax.swing.JPanel;
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
public class Loading3 extends Stage4 {
|
482
|
+
|
483
|
+
JButton btn1,btn2;
|
484
|
+
|
485
|
+
public Loading3(MainFrame m,String s){
|
486
|
+
|
487
|
+
super(m,s);
|
488
|
+
|
489
|
+
btn.setText("0000000000");
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
@Override
|
494
|
+
|
495
|
+
public void pc(){
|
496
|
+
|
497
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[4]);
|
498
|
+
|
499
|
+
}
|
500
|
+
|
501
|
+
}
|
502
|
+
|
503
|
+
```
|
48
504
|
|
49
505
|
|
50
506
|
|
1
実行結果追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ボタンに画像を貼り付ける方法がわからない
|
1
|
+
![実行するとこうなります](2000db0743dbb5a18bd436533a48fe8e.png)ボタンに画像を貼り付ける方法がわからない
|
2
2
|
|
3
3
|
```Java
|
4
4
|
|
@@ -28,6 +28,8 @@
|
|
28
28
|
|
29
29
|
button1.setText("カービィ ");
|
30
30
|
|
31
|
+
p.add(button1);
|
32
|
+
|
31
33
|
|
32
34
|
|
33
35
|
}
|