-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.java
58 lines (49 loc) · 1.16 KB
/
display.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
public class display extends JFrame {
private static final long serialVersionUID = 1L;
private static Dimension d = new Dimension(800,835);
static BufferStrategy bs;
private static Canvas cs;
static Graphics g;
static keybinder keyb = new keybinder();
display() throws Exception
{
setSize(d);
setTitle("2048");
setResizable(false);
setLocationRelativeTo(null);
cs = new Canvas();
cs.setPreferredSize(d);
cs.setMaximumSize(d);
cs.setMinimumSize(d);
cs.setFocusable(false);
add(cs);
addKeyListener(keyb);
setVisible(true);
}
static void draw()
{
bs = cs.getBufferStrategy();
if(bs==null)
{
cs.createBufferStrategy(3);
}
bs = cs.getBufferStrategy();
g = bs.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillRect( 0, 0, 800, 800);
g.setColor(Color.white);
g.drawLine(200, 0, 200, 800);
g.drawLine(400, 0, 400, 800);
g.drawLine(600, 0, 600, 800);
g.drawLine(0, 200, 800, 200);
g.drawLine(0, 400, 800, 400);
g.drawLine(0, 600, 800, 600);
//bs.show();
}
}