-
Notifications
You must be signed in to change notification settings - Fork 0
/
Title.java
51 lines (39 loc) · 1.08 KB
/
Title.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
package shooting;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
public class Title extends JPanel implements KeyListener {
public static final int WIDTH=640;
public static final int HEIGHT=480;
private Image image;
public Title() {
setPreferredSize(new Dimension(WIDTH,HEIGHT));
setFocusable(true);
addKeyListener(this);
ImageIcon icon=new ImageIcon(getClass().getResource("image/2xcluster-900x504.png"));
image=icon.getImage();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image,0,0,null);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int key=e.getKeyCode();
if(key==KeyEvent.VK_ENTER) {
System.out.println("aaaa");
Invader.changeToGame();
}
}
@Override
public void keyReleased(KeyEvent e) {
// TODO 自動生æˆã•ã‚ŒãŸãƒ¡ã‚½ãƒ?ドã?»ã‚¹ã‚¿ãƒ?
}
}