forked from Kartikey0205/Colege-JavaLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXOgame.java
More file actions
34 lines (34 loc) · 795 Bytes
/
XOgame.java
File metadata and controls
34 lines (34 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package sample;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
public class Practical extends Application
{
@Override
public void start(Stage primaryStage)
{
GridPane pane = new GridPane();
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
int n = (int)(Math.random() * 3);
if (n == 0)
pane.add(new ImageView(new Image("images/X.png")), j, i);
else if (n == 1)
pane.add(new ImageView(new Image("images/O.png")), j, i);
else {
continue;
}
}
}
Scene scene = new Scene(pane, 120, 130);
primaryStage.setTitle("Practical");
primaryStage.setScene(scene);
primaryStage.show();
}
}