From 1ddc3206bb03b0d4e51e0f83e7597acdaee7bff4 Mon Sep 17 00:00:00 2001 From: pooja Date: Fri, 27 May 2022 15:49:54 +0530 Subject: [PATCH] topmovieFrame --- Favorite_Movies/src/Main_HomePage.java | 10 ++++ Favorite_Movies/src/TopMovieFrame.java | 74 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 Favorite_Movies/src/TopMovieFrame.java diff --git a/Favorite_Movies/src/Main_HomePage.java b/Favorite_Movies/src/Main_HomePage.java index 15a5d7f..e12045f 100644 --- a/Favorite_Movies/src/Main_HomePage.java +++ b/Favorite_Movies/src/Main_HomePage.java @@ -206,6 +206,16 @@ public class Main_HomePage extends JFrame { // upon selecting a genre from a dropdown list and clicking the button // it should call Database.findTopMovieByGenre(String genre) // this function will search all the records in the file and find the top movies by genre + + TopMovieFrame tmf=new TopMovieFrame(); + + tmf.setVisible(true); + if(tmf.isVisible()) { + //use to display only one screen + Main_HomePage.this.dispose(); + } + + } } }); diff --git a/Favorite_Movies/src/TopMovieFrame.java b/Favorite_Movies/src/TopMovieFrame.java new file mode 100644 index 0000000..f456e9a --- /dev/null +++ b/Favorite_Movies/src/TopMovieFrame.java @@ -0,0 +1,74 @@ +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 java.awt.Font; +import javax.swing.JTextField; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.DefaultComboBoxModel; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class TopMovieFrame extends JFrame { + + private JPanel contentPane; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + TopMovieFrame frame = new TopMovieFrame(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the frame. + */ + public TopMovieFrame() { + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setBounds(100, 100, 467, 333); + contentPane = new JPanel(); + contentPane.setBackground(new Color(0, 0, 51)); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + + JLabel lblSelectGenre = new JLabel("Select Genre :"); + lblSelectGenre.setForeground(Color.WHITE); + lblSelectGenre.setFont(new Font("Tahoma", Font.PLAIN, 14)); + lblSelectGenre.setBounds(116, 45, 162, 24); + contentPane.add(lblSelectGenre); + + JComboBox comboBox = new JComboBox(); + comboBox.setModel(new DefaultComboBoxModel(new String[] {"", "Comic", "Horror", "Comedy", "Drama", "Action", "Thriller"})); + comboBox.setToolTipText(""); + comboBox.setBounds(107, 100, 171, 22); + contentPane.add(comboBox); + + JButton btnOkTmg = new JButton("ok"); + btnOkTmg.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String genre=comboBox.getToolTipText().toString(); + Database.findTopMovieByGenre(genre); + + } + }); + btnOkTmg.setBounds(118, 154, 89, 23); + contentPane.add(btnOkTmg); + + + } +}