-
Notifications
You must be signed in to change notification settings - Fork 0
/
Introduction.java~
111 lines (108 loc) · 4.69 KB
/
Introduction.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
/**
* The is the GoodBye panel that is the outro screen.
*
* @author Eric Tu and Sejin Kwon
* @version 3
* @since June 1 2012
*/
public class Introduction extends JPanel implements ActionListener {
private Timer animator;
private JLabel flower1 = new JLabel (new ImageIcon ("RedFlower.png"));
private JLabel flower2 = new JLabel (new ImageIcon ("BlueFlower.png"));
private JLabel flower3 = new JLabel (new ImageIcon ("YellowFlower.png"));
private JLabel flower4 = new JLabel (new ImageIcon ("GreenFlower.png"));
private JLabel flower5 = new JLabel (new ImageIcon ("RedSpikyFlower.png"));
private JLabel flower6 = new JLabel (new ImageIcon ("BlueSpikyFlower.png"));
private JLabel flower7 = new JLabel (new ImageIcon ("YellowSpikyFlower.png"));
private JLabel flower8 = new JLabel (new ImageIcon ("GreenSpikyFlower.png"));
private JLabel logo = new JLabel (new ImageIcon ("munderdifflin.png"));
/**
* This starts the timer to call it's event methods after 4 seconds.
*/
public void start(){
animator = new Timer (1, this);
animator.start ();
}
/**
* The class constructor.
*
* Adds and creates a message saying bye.
*/
public Introduction(){
setLayout (null);
setPreferredSize(new Dimension (840,600));
logo.setBounds (158, 196, logo.getPreferredSize ().width, logo.getPreferredSize ().height);
flower1.setBounds (128, 260, flower1 .getPreferredSize ().width, flower1.getPreferredSize ().height);
flower2.setBounds (167, 167, flower2.getPreferredSize ().width, flower2.getPreferredSize ().height);
flower3.setBounds (285, 167, flower3.getPreferredSize ().width, flower3.getPreferredSize ().height);
flower4.setBounds (403, 167, flower4.getPreferredSize ().width, flower4.getPreferredSize ().height);
flower5.setBounds (441, 260, flower5.getPreferredSize ().width, flower5.getPreferredSize ().height);
flower6.setBounds (403, 374, flower6.getPreferredSize ().width, flower6.getPreferredSize ().height);
flower7.setBounds (285, 374, flower7.getPreferredSize ().width, flower7.getPreferredSize ().height);
flower8.setBounds (167, 374 , flower8.getPreferredSize ().width, flower8.getPreferredSize ().height);
add (flower1);
add (flower2);
add (flower3);
add (flower4);
add (flower5);
add (flower6);
add (flower7);
add (flower8);
add (logo);
}
public void actionPerformed (ActionEvent e)
{
if (flower1.getLocation ().getX() > 5)
{
flower1.setBounds ((int) (flower1.getLocation ().getX()- 1), 260, flower1.getPreferredSize ().width,flower1.getPreferredSize ().height);
}
else if (flower2.getLocation ().getX () > 5)
{
flower2.setBounds ((int) (flower2.getLocation ().getX()- 1), (int) (flower2.getLocation ().getY() - 1), flower2.getPreferredSize ().width,flower2.getPreferredSize ().height);
}
else if (flower3.getLocation ().getY () > 5)
{
flower3.setBounds (285, (int) (flower3.getLocation ().getY() - 1), flower3.getPreferredSize ().width,flower3.getPreferredSize ().height);
}
else if (flower4.getLocation ().getX () < 565)
{
flower4.setBounds ((int) (flower4.getLocation ().getX() + 1), (int) (flower4.getLocation ().getY() - 1), flower4.getPreferredSize ().width,flower4.getPreferredSize ().height);
}
else if (flower5.getLocation ().getX () < 565)
{
flower5.setBounds ((int) (flower5.getLocation ().getX() + 1), 260, flower5.getPreferredSize ().width,flower5.getPreferredSize ().height);
}
else if (flower6.getLocation ().getX () < 565)
{
flower6.setBounds ((int) (flower6.getLocation ().getX() + 1), (int) (flower6.getLocation ().getY() + 1), flower6.getPreferredSize ().width,flower6.getPreferredSize ().height);
}
else if (flower7.getLocation ().getY () < 565)
{
flower7.setBounds (285, (int) (flower7.getLocation ().getY() + 1), flower7.getPreferredSize ().width,flower7.getPreferredSize ().height);
}
else if (flower8.getLocation ().getX () > 5)
{
flower8.setBounds ((int) (flower8.getLocation ().getX() - 1), (int) (flower8.getLocation ().getY() + 1), flower8.getPreferredSize ().width,flower8.getPreferredSize ().height);
}
else if (animator.getDelay () == 1)
{
animator.setDelay (3000);
removeAll ();
JLabel message = new JLabel (new ImageIcon ("Hellomessage.png"));
message.setBounds (100, 150,message.getPreferredSize ().width, message.getPreferredSize ().height);
add (message);
}
else
{
if (animator.getDelay () ==3000)
{
FrameApp.cardLayout.show (FrameApp.mainPanel, FrameApp.MAINMENU);
animator.stop ();
}
}
updateUI ();
}
}