-
Notifications
You must be signed in to change notification settings - Fork 2
/
MovieGUI2.java
142 lines (123 loc) · 4.45 KB
/
MovieGUI2.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package First;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSlider;
import java.awt.GridLayout;
import java.net.MalformedURLException;
import java.net.URL;
import java.awt.event.*;
/**
* A JFrame class for the GUI design and the method of reminding the password
* @author Burak Mete Canpınar
* @version 4.23
*/
public class MovieGUI2 extends JFrame {
private JPanel contentPane;
Movie m;
User u;
String genres_string="";
String companies_string="";
String languages_string="";
String countries_string="";
Integer[] nums = {1,2,3,4,5,6,7,8,9,10};
JComboBox votebox;
int selected = 0;
JButton btnNewButton;
/**
* MovieGUI2 class for the design of movie page
* @param u user object
* @param m movie object
*/
public MovieGUI2(Movie m, User u) {
this.m = m;
this.u=u;
//for loops to generate strings for specified ArrayLists
for(int i=0;i<m.genres.size();i++)
genres_string+=m.genres.get(i).name + ",";
for(int i=0;i<m.production_companies.size();i++)
companies_string+=m.production_companies.get(i).name + ",";
for(int i=0;i<m.spoken_languages.size();i++)
languages_string+=m.spoken_languages.get(i).name + ",";
for(int i=0;i<m.production_countries.size();i++)
countries_string+=m.production_countries.get(i).name + ",";
setTitle(m.title);
setVisible(true);
ImageIcon icon = null;
try {
icon = new ImageIcon(new URL("http://cf2.imgobject.com/t/p/w185/"+m.poster_path));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 599, 383);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JPanel panel = new JPanel();
panel.setBounds(0, 0, 163, 222);
contentPane.add(panel);
panel.setLayout(new GridLayout(1, 0, 0, 0));
JLabel image=new JLabel(icon);
panel.add(image);
btnNewButton = new JButton("Vote,add to your watchlist");
btnNewButton.setBounds(0, 230, 163, 37);
contentPane.add(btnNewButton);
if(!Database.isWatched(u, m))
btnNewButton.setEnabled(true);
else
btnNewButton.setEnabled(false);
btnNewButton.addActionListener(new ButtonListener());
JLabel lblMoveTtle = new JLabel(m.original_title);
lblMoveTtle.setBounds(173, 11, 317, 14);
contentPane.add(lblMoveTtle);
JLabel lblRating = new JLabel(""+m.vote_average);
lblRating.setBounds(173, 68, 46, 14);
contentPane.add(lblRating);
votebox = new JComboBox(nums);
votebox.setBounds(229, 59, 200, 23);
contentPane.add(votebox);
JLabel lblGenres = new JLabel("Genres: "+genres_string);
lblGenres.setBounds(173, 219, 317, 14);
contentPane.add(lblGenres);
JLabel lblRuntime = new JLabel("Runtime: "+m.runtime);
lblRuntime.setBounds(183, 31, 100, 14);
contentPane.add(lblRuntime);
JLabel lblReleaseDate = new JLabel("Release date: "+m.release_date);
lblReleaseDate.setBounds(309, 31, 174, 14);
contentPane.add(lblReleaseDate);
JLabel lblVotes = new JLabel(m.vote_count+" votes");
lblVotes.setBounds(439, 68, 71, 14);
contentPane.add(lblVotes);
JLabel lblBudget = new JLabel("Budget: "+m.budget);
lblBudget.setBounds(173, 109, 142, 14);
contentPane.add(lblBudget);
JLabel lblRevenue = new JLabel("Revenue: "+m.revenue);
lblRevenue.setBounds(325, 109, 163, 14);
contentPane.add(lblRevenue);
JLabel lblSpokenLanguages = new JLabel("Spoken Languages: "+languages_string);
lblSpokenLanguages.setBounds(173, 144, 337, 14);
contentPane.add(lblSpokenLanguages);
JLabel lblCompanies = new JLabel("Companies: "+companies_string);
lblCompanies.setBounds(173, 169, 337, 14);
contentPane.add(lblCompanies);
JLabel lblCompanies_1 = new JLabel("Countries: "+countries_string);
lblCompanies_1.setBounds(173, 194, 337, 14);
contentPane.add(lblCompanies_1);
}
class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent evt){
int vote = ((Integer) votebox.getSelectedItem()).intValue();
Database.addWatchedList(u, m, vote);
btnNewButton.setEnabled(false);
}
}
}