質問編集履歴
4
文章の読みやすさ
title
CHANGED
File without changes
|
body
CHANGED
@@ -100,9 +100,9 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
}
|
103
|
+
```
|
103
104
|
```Java
|
104
|
-
コード
|
105
|
-
|
105
|
+
コードpackage gazou;
|
106
106
|
|
107
107
|
import java.awt.Color;
|
108
108
|
import java.awt.event.ActionEvent;
|
@@ -165,6 +165,7 @@
|
|
165
165
|
}
|
166
166
|
}
|
167
167
|
|
168
|
+
```
|
168
169
|
```java
|
169
170
|
package gazou;
|
170
171
|
|
@@ -234,7 +235,8 @@
|
|
234
235
|
mf.PanelChange((JPanel)this, mf.PanelNames[3]);
|
235
236
|
}
|
236
237
|
}
|
238
|
+
```
|
237
|
-
```
|
239
|
+
```Java
|
238
240
|
コードpackage gazou;
|
239
241
|
|
240
242
|
import javax.swing.JButton;
|
3
イメージ追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+

|
1
2
|
```JAVA
|
2
3
|
コードpackage gazou;
|
3
4
|
|
@@ -99,8 +100,9 @@
|
|
99
100
|
|
100
101
|
|
101
102
|
}
|
102
|
-
```
|
103
|
+
```Java
|
104
|
+
コード
|
103
|
-
|
105
|
+
```package gazou;
|
104
106
|
|
105
107
|
import java.awt.Color;
|
106
108
|
import java.awt.event.ActionEvent;
|
@@ -161,8 +163,8 @@
|
|
161
163
|
public void pc(){
|
162
164
|
mf.PanelChange((JPanel)this,mf.PanelNames[1]);
|
163
165
|
}
|
164
|
-
}```java
|
165
|
-
|
166
|
+
}
|
167
|
+
|
166
168
|
```java
|
167
169
|
package gazou;
|
168
170
|
|
2
Mainframe Taitoru0 Mode1 Cara2 Loading3 の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,215 @@
|
|
1
|
+
```JAVA
|
2
|
+
コードpackage gazou;
|
3
|
+
|
4
|
+
import javax.swing.JFrame;
|
5
|
+
import javax.swing.JPanel;
|
6
|
+
|
7
|
+
public class MainFrame extends JFrame{
|
8
|
+
|
9
|
+
public String[] PanelNames = {"mp","1","2","3","4","5","6","7","8","9"};
|
10
|
+
Taitoru0 mp = new Taitoru0(this,PanelNames[0]);
|
11
|
+
Mode1 sp = new Mode1(this,PanelNames[1]);
|
12
|
+
Cara2 sp2 = new Cara2(this,PanelNames[2]);
|
13
|
+
Loading3 sp3 = new Loading3(this,PanelNames[3]);
|
14
|
+
Stage4 sp4 = new Stage4(this,PanelNames[4]);
|
15
|
+
VS5 sp5 = new VS5(this,PanelNames[5]);
|
16
|
+
Batoru6 sp6 = new Batoru6(this,PanelNames[6]);
|
17
|
+
Result7 sp7 = new Result7(this,PanelNames[7]);
|
18
|
+
// bunki8 sp8 = new bunki8(this,PanelNames[8]);
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
public MainFrame(){
|
23
|
+
this.add(mp);mp.setVisible(true);
|
24
|
+
this.add(sp);sp.setVisible(false);
|
25
|
+
this.add(sp2);sp2.setVisible(false);
|
26
|
+
this.add(sp3);sp3.setVisible(false);
|
27
|
+
this.add(sp4);sp4.setVisible(false);
|
28
|
+
this.add(sp5);sp5.setVisible(false);
|
29
|
+
this.add(sp6);sp6.setVisible(false);
|
30
|
+
this.add(sp7);sp7.setVisible(false);
|
31
|
+
// this.add(sp8);sp8.setVisible(false);
|
32
|
+
// this.add(sp9);sp9.setVisible(false);
|
33
|
+
|
34
|
+
this.setBounds(100, 100, 800, 600);
|
35
|
+
}
|
36
|
+
public static void main(String[] args) {
|
37
|
+
MainFrame mf = new MainFrame();
|
38
|
+
mf.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
39
|
+
mf.setTitle("ACE DREAM MATCH");//タイトルバーの名前
|
40
|
+
mf.setVisible(true);
|
41
|
+
}
|
42
|
+
public void PanelChange(JPanel jp, String str){
|
43
|
+
System.out.println(jp.getName());
|
44
|
+
String name = jp.getName();
|
45
|
+
if(name==PanelNames[0]){
|
46
|
+
mp = (Taitoru0)jp;
|
47
|
+
mp.setVisible(false);
|
48
|
+
}else if(name==PanelNames[1]){
|
49
|
+
sp = (Mode1)jp;
|
50
|
+
sp.setVisible(false);
|
51
|
+
}else if(name==PanelNames[2]){
|
52
|
+
sp2 = (Cara2)jp;
|
53
|
+
sp2.setVisible(false);
|
54
|
+
}else if(name==PanelNames[3]){
|
55
|
+
sp3 = (Loading3)jp;
|
56
|
+
sp3.setVisible(false);
|
57
|
+
}else if(name==PanelNames[4]){
|
58
|
+
sp4 = (Stage4)jp;
|
59
|
+
sp4.setVisible(false);
|
60
|
+
}else if(name==PanelNames[5]){
|
61
|
+
sp5 = (VS5)jp;
|
62
|
+
sp5.setVisible(false);
|
63
|
+
}else if(name==PanelNames[6]){
|
64
|
+
sp6 = (Batoru6)jp;
|
65
|
+
sp6.setVisible(false);
|
66
|
+
}else if(name==PanelNames[7]){
|
67
|
+
sp7 = (Result7)jp;
|
68
|
+
sp7.setVisible(false);
|
69
|
+
}//else if(name==PanelNames[8]){
|
70
|
+
// sp8 = (bunki8)jp;
|
71
|
+
// sp8.setVisible(false);
|
72
|
+
// }//else if(name==PanelNames[9]){
|
73
|
+
// sp9 = (Mode1_m9)jp;
|
74
|
+
// sp9.setVisible(false);
|
75
|
+
//}
|
76
|
+
if(str==PanelNames[0]){
|
77
|
+
mp.setVisible(true);
|
78
|
+
}else if(str==PanelNames[1]){
|
79
|
+
sp.setVisible(true);
|
80
|
+
}else if(str==PanelNames[2]){
|
81
|
+
sp2.setVisible(true);
|
82
|
+
}else if(str==PanelNames[3]){
|
83
|
+
sp3.setVisible(true);
|
84
|
+
}else if(str==PanelNames[4]){
|
85
|
+
sp4.setVisible(true);
|
86
|
+
}else if(str==PanelNames[5]){
|
87
|
+
sp5.setVisible(true);
|
88
|
+
}else if(str==PanelNames[6]){
|
89
|
+
sp6.setVisible(true);
|
90
|
+
}else if(str==PanelNames[7]){
|
91
|
+
sp7.setVisible(true);
|
92
|
+
}/*else if(str==PanelNames[8]){
|
93
|
+
sp8.setVisible(true);
|
94
|
+
}
|
95
|
+
//else if(str==PanelNames[9]){
|
96
|
+
// sp9.setVisible(true);
|
97
|
+
//}*/
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
}
|
102
|
+
```JAVA
|
103
|
+
コードpackage gazou;
|
104
|
+
|
105
|
+
import java.awt.Color;
|
106
|
+
import java.awt.event.ActionEvent;
|
107
|
+
import java.awt.event.ActionListener;
|
108
|
+
|
109
|
+
import javax.swing.JButton;
|
110
|
+
import javax.swing.JLabel;
|
111
|
+
import javax.swing.JPanel;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
public class Taitoru0 extends JPanel {
|
116
|
+
JButton btn,btn2,btn3;
|
117
|
+
JLabel paneltitle;
|
118
|
+
MainFrame mf;
|
119
|
+
String str;
|
120
|
+
|
121
|
+
public Taitoru0(MainFrame m,String s){
|
122
|
+
mf = m;
|
123
|
+
str = s;
|
124
|
+
this.setName("mp");
|
125
|
+
this.setLayout(null);
|
126
|
+
this.setSize(500, 400);
|
127
|
+
paneltitle = new JLabel("これは"
|
128
|
+
+getClass().getCanonicalName()+"タイトルクラスのパネルです");
|
129
|
+
paneltitle.setBounds(0, 5, 400, 40);
|
130
|
+
this.add(paneltitle);
|
131
|
+
//
|
132
|
+
btn = new JButton("モード選択に移動");
|
133
|
+
btn.setBounds(20, 50, 150, 40);
|
134
|
+
btn.addActionListener(new ActionListener(){
|
135
|
+
public void actionPerformed(ActionEvent e){
|
136
|
+
pc();
|
137
|
+
}
|
138
|
+
});
|
139
|
+
this.add(btn);
|
140
|
+
/*
|
141
|
+
btn2 = new JButton("SubPanel2に移動");
|
142
|
+
btn2.setBounds(20, 100, 150, 40);
|
143
|
+
btn2.addActionListener(new ActionListener(){
|
144
|
+
public void actionPerformed(ActionEvent e){
|
145
|
+
pc(mf.PanelNames[2]);
|
146
|
+
}
|
147
|
+
});
|
148
|
+
this.add(btn2);
|
149
|
+
btn3 = new JButton("SubPanel3に移動");
|
150
|
+
btn3.setBounds(200, 100, 150, 40);
|
151
|
+
btn3.addActionListener(new ActionListener(){
|
152
|
+
public void actionPerformed(ActionEvent e){
|
153
|
+
pc(mf.PanelNames[3]);
|
154
|
+
}
|
155
|
+
});
|
156
|
+
this.add(btn3);*/
|
157
|
+
Float f = (float) Math.random();
|
158
|
+
this.setBackground(Color.getHSBColor(f, 0.9f, 0.9f));
|
159
|
+
|
160
|
+
}
|
161
|
+
public void pc(){
|
162
|
+
mf.PanelChange((JPanel)this,mf.PanelNames[1]);
|
163
|
+
}
|
164
|
+
}```java
|
165
|
+
コード
|
166
|
+
```java
|
167
|
+
package gazou;
|
168
|
+
|
169
|
+
import java.awt.event.ActionEvent;
|
170
|
+
import java.awt.event.ActionListener;
|
171
|
+
|
172
|
+
import javax.swing.JButton;
|
173
|
+
import javax.swing.JPanel;
|
174
|
+
|
175
|
+
|
176
|
+
public class Mode1 extends Cara2 {
|
177
|
+
JButton btn1,btn2;
|
178
|
+
public Mode1(MainFrame m,String s){
|
179
|
+
super(m,s);
|
180
|
+
mf = m;
|
181
|
+
str = s;
|
182
|
+
btn1 = new JButton("シングルプレイ");
|
183
|
+
btn1.setBounds(20, 50, 150, 40);
|
184
|
+
btn1.addActionListener(new ActionListener(){
|
185
|
+
public void actionPerformed(ActionEvent e){
|
186
|
+
pc();
|
187
|
+
}
|
188
|
+
});
|
189
|
+
this.add(btn1);
|
190
|
+
//
|
191
|
+
btn2 = new JButton("マルチプレイ");
|
192
|
+
btn2.setBounds(20, 100, 150, 40);
|
193
|
+
btn2.addActionListener(new ActionListener(){
|
194
|
+
public void actionPerformed(ActionEvent e){
|
195
|
+
pc();
|
196
|
+
}
|
197
|
+
});
|
198
|
+
this.add(btn2);
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
@Override
|
204
|
+
public void pc(){
|
205
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[2]);
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
```
|
1
|
-
ボタンに画像を貼り付ける方法がわからない
|
212
|
+
```ボタンに画像を貼り付ける方法がわからない
|
2
213
|
```Java
|
3
214
|
コードimport javax.swing.ImageIcon;
|
4
215
|
import javax.swing.JButton;
|
@@ -21,7 +232,24 @@
|
|
21
232
|
mf.PanelChange((JPanel)this, mf.PanelNames[3]);
|
22
233
|
}
|
23
234
|
}
|
235
|
+
```java
|
236
|
+
コードpackage gazou;
|
24
237
|
|
238
|
+
import javax.swing.JButton;
|
239
|
+
import javax.swing.JPanel;
|
25
240
|
|
241
|
+
public class Loading3 extends Stage4 {
|
242
|
+
JButton btn1,btn2;
|
243
|
+
public Loading3(MainFrame m,String s){
|
244
|
+
super(m,s);
|
245
|
+
btn.setText("0000000000");
|
246
|
+
}
|
247
|
+
@Override
|
248
|
+
public void pc(){
|
249
|
+
mf.PanelChange((JPanel)this, mf.PanelNames[4]);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
```
|
253
|
+
|
26
254
|
```[引用サイト](https://www.javadrive.jp/tutorial/jbutton/index8.html)
|
27
255
|
[引用サイト2](http://nowloading.blog.jp/archives/36741210.html)
|
1
実行結果追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ボタンに画像を貼り付ける方法がわからない
|
1
|
+
ボタンに画像を貼り付ける方法がわからない
|
2
2
|
```Java
|
3
3
|
コードimport javax.swing.ImageIcon;
|
4
4
|
import javax.swing.JButton;
|
@@ -13,6 +13,7 @@
|
|
13
13
|
button1.setIcon(icon1);
|
14
14
|
button1.setBounds(20, 50, 150, 40);
|
15
15
|
button1.setText("カービィ ");
|
16
|
+
p.add(button1);
|
16
17
|
|
17
18
|
}
|
18
19
|
@Override
|