Last active
August 29, 2015 14:06
-
-
Save LordNairu/7494e99795cfa985d348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gui; | |
import java.awt.BorderLayout; | |
import java.awt.Dimension; | |
import java.awt.GridBagConstraints; | |
import java.awt.GridBagLayout; | |
import java.awt.Insets; | |
import javax.swing.BorderFactory; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JPanel; | |
import javax.swing.JTextArea; | |
import cinema.Film; | |
public class FilmInfoFrame extends JFrame { | |
private static final long serialVersionUID = 3405364316894635254L; | |
private Film film; | |
private final JLabel titleDisplay = new JLabel(""); | |
private final JLabel directorDisplay = new JLabel(""); | |
private final JLabel producerDisplay = new JLabel(""); | |
private final JLabel castDisplay1 = new JLabel(""); | |
private final JLabel castDisplay2 = new JLabel(""); | |
private final JLabel castDisplay3 = new JLabel(""); | |
private final JLabel threeDDisplay = new JLabel(""); | |
public FilmInfoFrame (String title){ | |
super(title); | |
this.setSize(500, 500); | |
// Set layout | |
setLayout(new BorderLayout()); | |
//Create content panel | |
JPanel infoPanel = new JPanel(); | |
Dimension size = getPreferredSize(); | |
size.width = 250; | |
size.height = 250; | |
infoPanel.setPreferredSize(size); | |
infoPanel.setBorder(BorderFactory.createTitledBorder("Information")); | |
// Create information label | |
final JLabel filmTitle = new JLabel("Film Title:"); | |
final JLabel directorLabel = new JLabel("Director:"); | |
final JLabel producerLabel = new JLabel("Producer:"); | |
final JLabel castLabel = new JLabel("Cast:"); | |
final JLabel threeDLabel = new JLabel("3D:"); | |
final JTextArea textArea = new JTextArea(); | |
GridBagConstraints gridBag = new GridBagConstraints(); | |
gridBag.insets = new Insets(3, 3, 3, 3); | |
infoPanel.setLayout(new GridBagLayout()); | |
// Add component First Column | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 5.5; | |
gridBag.weighty = 5.5; | |
gridBag.gridx = 0; | |
gridBag.gridy = 0; | |
infoPanel.add(filmTitle, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 0; | |
gridBag.gridy = 1; | |
infoPanel.add(directorLabel, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 0; | |
gridBag.gridy = 2; | |
infoPanel.add(producerLabel, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 0; | |
gridBag.gridy = 3; | |
infoPanel.add(castLabel, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 0; | |
gridBag.gridy = 6; | |
infoPanel.add(threeDLabel, gridBag); | |
/////////// Second column | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 0; | |
infoPanel.add(titleDisplay, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 1; | |
infoPanel.add(directorDisplay, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 2; | |
infoPanel.add(producerDisplay, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 3; | |
infoPanel.add(castDisplay1, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 4; | |
infoPanel.add(castDisplay2, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 5; | |
infoPanel.add(castDisplay3, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 1; | |
gridBag.gridy = 6; | |
infoPanel.add(threeDDisplay, gridBag); | |
gridBag.anchor = GridBagConstraints.NORTHWEST; | |
gridBag.weightx = 0.5; | |
gridBag.weighty = 0.5; | |
gridBag.gridx = 2; | |
gridBag.gridy = 7; | |
infoPanel.add(textArea, gridBag); | |
this.add(infoPanel, BorderLayout.CENTER); | |
this.pack(); | |
this.setVisible(false); | |
} | |
public Film getFilm(){ | |
return this.film; | |
} | |
public void setFilm(Film film){ | |
this.film = film; | |
} | |
public String threeD (Film film){ | |
String answer = ""; | |
if (film.getIs3D()){ | |
answer = "Yes"; | |
} else { | |
answer = "No"; | |
} | |
return answer; | |
} | |
public void setFilmInformation(Film film){ | |
this.setFilm(film); | |
this.titleDisplay.setText(film.getFilmTitle()); | |
this.directorDisplay.setText(film.getFilmDirector()); | |
this.producerDisplay.setText(film.getFilmProducer()); | |
this.castDisplay1.setText(film.getCastMember1()); | |
this.castDisplay2.setText(film.getCastMember2()); | |
this.castDisplay3.setText(film.getCastMember3()); | |
this.threeDDisplay.setText(threeD(film)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment