質問編集履歴

1

コードを記載致しました

2017/06/06 06:28

投稿

javasyosinnsya1
javasyosinnsya1

スコア26

test CHANGED
File without changes
test CHANGED
@@ -5,3 +5,203 @@
5
5
  何か良い方法がありましたら教えてください。
6
6
 
7
7
  よろしくお願い致します。
8
+
9
+ (なお、タイトル画面、ゲーム画面共にまだまだ未完成の状態となっております)
10
+
11
+ ```java
12
+
13
+ コード(タイトル画面)
14
+
15
+ import javafx.application.Application;
16
+
17
+ import javafx.event.ActionEvent;
18
+
19
+ import javafx.event.EventHandler;
20
+
21
+ import javafx.scene.Scene;
22
+
23
+ import javafx.scene.control.Alert;
24
+
25
+ import javafx.scene.control.Button;
26
+
27
+ import javafx.scene.control.Label;
28
+
29
+ import javafx.scene.layout.BorderPane;
30
+
31
+ import javafx.stage.Stage;
32
+
33
+
34
+
35
+ public class samaple extends Application{
36
+
37
+
38
+
39
+ private Label lb;
40
+
41
+ private Button bt1, bt2;
42
+
43
+
44
+
45
+ public static void main(String[] args)
46
+
47
+ {
48
+
49
+ launch(args);
50
+
51
+ }
52
+
53
+
54
+
55
+ @Override
56
+
57
+ public void start(Stage stage) throws Exception {
58
+
59
+ // TODO 自動生成されたメソッド・スタブ
60
+
61
+
62
+
63
+ lb = new Label(" 五目並べ");
64
+
65
+ bt1 = new Button("ルール説明");
66
+
67
+ bt2 = new Button("スタート");
68
+
69
+
70
+
71
+ BorderPane bp = new BorderPane();
72
+
73
+
74
+
75
+ bp.setTop(lb);
76
+
77
+ bp.setBottom(bt1);
78
+
79
+ bp.setCenter(bt2);
80
+
81
+
82
+
83
+ bt1.setOnAction(new SampleEventHandler());
84
+
85
+
86
+
87
+ Scene sc = new Scene(bp, 300, 200);
88
+
89
+
90
+
91
+ stage.setScene(sc);
92
+
93
+ stage.setTitle("五目並べ");
94
+
95
+ stage.show();
96
+
97
+
98
+
99
+
100
+
101
+ }
102
+
103
+
104
+
105
+ class SampleEventHandler implements
106
+
107
+ EventHandler<ActionEvent>
108
+
109
+ {
110
+
111
+ public void handle(ActionEvent e)
112
+
113
+ {
114
+
115
+ Alert al = new Alert(Alert.AlertType.INFORMATION);
116
+
117
+ al.setTitle("ルール説明");
118
+
119
+ al.getDialogPane()
120
+
121
+ .setHeaderText(" ルール説明\n1:五目並べのルール");
122
+
123
+ al.show();
124
+
125
+
126
+
127
+ }
128
+
129
+ }
130
+
131
+
132
+
133
+ コード(ゲーム画面)
134
+
135
+ import javafx.application.Application;
136
+
137
+ import javafx.scene.Scene;
138
+
139
+ import javafx.scene.control.Button;
140
+
141
+ import javafx.scene.layout.GridPane;
142
+
143
+ import javafx.stage.Stage;
144
+
145
+
146
+
147
+ public class sample2 extends Application
148
+
149
+ {
150
+
151
+ private Button[][] bt = new Button[5][5];
152
+
153
+
154
+
155
+ public static void main(String[] args)
156
+
157
+ {
158
+
159
+ launch(args);
160
+
161
+ }
162
+
163
+ @Override
164
+
165
+ public void start(Stage stage) throws Exception
166
+
167
+ {
168
+
169
+ for(int m=0; m<bt.length; m++){
170
+
171
+ for(int c=0; c<bt[m].length; c++){
172
+
173
+ bt[m][c] = new Button(Integer.toString(c) + Integer.toString(m));
174
+
175
+ }
176
+
177
+ }
178
+
179
+ GridPane gp = new GridPane();
180
+
181
+
182
+
183
+ for(int m=0; m<bt.length; m++){
184
+
185
+ for(int c=0; c<bt.length; c++){
186
+
187
+ gp.add(bt[m][c], m, c);
188
+
189
+ }
190
+
191
+ }
192
+
193
+
194
+
195
+ Scene sc = new Scene(gp, 248, 200);
196
+
197
+ stage.setScene(sc);
198
+
199
+ stage.setTitle("五目並べ");
200
+
201
+ stage.show();
202
+
203
+ }
204
+
205
+ }
206
+
207
+ ```