-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTopMovies.java
66 lines (61 loc) · 1.85 KB
/
TopMovies.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
package First;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Panel;
import java.net.MalformedURLException;
import java.net.URL;
import java.awt.event.*;
/**
* This is the TopMovies panel which is opened when the user clicks
* the Top movies button in the MovieGUI panel.
* @author Hasan Uygurer
* @version 4.22
*/
public class TopMovies extends JPanel {
/**
* Create the panel.
*/
private ImageIcon icon;
private JButton[] button = new JButton[34];
JScrollPane jScroll;
JPanel content;
Movies m=Database.getTopMovies();
User u;
//@param u gets the User object
public TopMovies(User u) {
this.u = u;
setLayout(new BorderLayout());
content = new JPanel();
content.setLayout(new GridLayout(5,6));
for(int i=0 ; i<m.results.size() ; i++){
try {
icon = new ImageIcon(new URL("http://cf2.imgobject.com/t/p/w92/"+m.results.get(i).poster_path));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
button[i] = new JButton(icon);
button[i].addActionListener(new ButtonListener());
//image.setBounds(10, 10, 92, 128);
content.add(button[i]);
content.setBounds(10,10,500,1000);
jScroll = new JScrollPane(content,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(jScroll, BorderLayout.CENTER);
}
}
class ButtonListener implements java.awt.event.ActionListener{
public void actionPerformed(java.awt.event.ActionEvent evt){
for(int i=0 ; i<m.results.size() ; i++){
if(button[i]==evt.getSource()){
MovieGUI2 movies = new MovieGUI2(m.results.get(i),u);
}
}
}
}
}