Browse Source

updated

master
mac 3 years ago
parent
commit
4bfd86ab07
1 changed files with 75 additions and 0 deletions
  1. 75
      Favorite_Movies/src/ShowMoviesForStarFrame.java

75
Favorite_Movies/src/ShowMoviesForStarFrame.java

@ -0,0 +1,75 @@
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JList;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.awt.event.ActionEvent;
public class ShowMoviesForStarFrame extends JFrame {
private JPanel contentPane;
private JTextField tf_starName;
private JList lMovies;
/**
* Create the frame.
*/
public ShowMoviesForStarFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 378, 375);
contentPane = new JPanel();
contentPane.setBackground(new Color(0, 0, 51));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("Enter Star Name:");
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 14));
lblNewLabel.setForeground(new Color(255, 255, 255));
lblNewLabel.setBounds(66, 91, 162, 24);
contentPane.add(lblNewLabel);
tf_starName = new JTextField();
tf_starName.setBounds(66, 129, 210, 24);
contentPane.add(tf_starName);
tf_starName.setColumns(10);
lMovies = new JList();
lMovies.setFont(new Font("Tahoma", Font.PLAIN, 14));
lMovies.setForeground(new Color(255, 255, 255));
lMovies.setBounds(66, 160, 210, 100);
contentPane.add(lMovies);
JButton btnOkSM = new JButton("ok");
btnOkSM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ArrayList<Movie> movies = Database.findMoviesForStar(tf_starName.getText());
if (movies.size()>0)
{
JOptionPane.showMessageDialog(null, "Movies Found for Star!");
for(Movie m: movies)
{
lMovies.add(new JLabel(m.getTitle()));
}
}
else {
JOptionPane.showMessageDialog(null, "Title not found !!");
}
}
});
btnOkSM.setBounds(68, 300, 89, 23);
contentPane.add(btnOkSM);
}
}
Loading…
Cancel
Save