-
Notifications
You must be signed in to change notification settings - Fork 0
/
ss.java
76 lines (60 loc) · 1.94 KB
/
ss.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class ss extends JFrame implements ActionListener {
JLabel pic;
Timer tm;
JButton b1;
int x = 0;
String[] list = { "images/kimono.png", "images/hobbit.jpg", "images/mr.png", "images/mjd.png", "images/oscar.png",
"images/gollum.png", "images/matx.png", "images/gf.jpg", "images/harry.png", "images/TH.png"
};
public ss() {
super("Project SlideShow");
pic = new JLabel();
pic.setBounds(0, 0, 1000, 600);
b1 = new JButton("Back");
b1.setBackground(Color.BLACK);
b1.setForeground(Color.RED);
b1.addActionListener(this);
b1.setBounds(390, 500, 180, 40);
add(b1);
setImageSize(9);
tm = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
setImageSize(x);
x += 1;
if (x >= list.length) {
x = 0;
// new test();
// System.exit(0);
}
}
});
add(pic);
tm.start();
setLayout(null);
setSize(1000, 600);
getContentPane().setBackground(Color.BLACK);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1) {
this.setVisible(false);
new test();
}
}
public void setImageSize(int i) {
ImageIcon icon = new ImageIcon(list[i]);
Image img = icon.getImage();
Image newimg = img.getScaledInstance(pic.getWidth(), pic.getHeight(), Image.SCALE_SMOOTH);
ImageIcon newImc = new ImageIcon(newimg);
pic.setIcon(newImc);
}
public static void main(String[] args) {
new ss();
}
}