Browse Source

added_smf

master
pooja 3 years ago
parent
commit
521d4912ea
2 changed files with 158 additions and 0 deletions
  1. 81
      Favorite_Movies/src/Main_HomePage.java
  2. 77
      Favorite_Movies/src/ShowMovieFrame.java

81
Favorite_Movies/src/Main_HomePage.java

@ -1,3 +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.GridLayout; import
* javax.swing.JButton; import java.awt.Color; import
* java.awt.event.ActionListener; import java.awt.event.ActionEvent;
*
* public class Main_HomePage extends JFrame {
*
* private JPanel contentPane;
*
*//**
* Launch the application.
*/
/*
* public static void main(String[] args) { EventQueue.invokeLater(new
* Runnable() { public void run() { try { Main_HomePage frame = new
* Main_HomePage(); frame.setVisible(true); } catch (Exception e) {
* e.printStackTrace(); } } }); }
*
*//**
* Create the frame.
*//*
* public Main_HomePage() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
* setBounds(100, 100, 271, 358); contentPane = new JPanel();
* contentPane.setBackground(new Color(0, 0, 51)); contentPane.setBorder(new
* EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane);
* contentPane.setLayout(null);
*
* JPanel panel = new JPanel(); panel.setBackground(new Color(0, 0, 51));
* panel.setBounds(50, 31, 155, 249); contentPane.add(panel);
* panel.setLayout(null);
*
* JButton btnMovies = new JButton("Movie"); btnMovies.addActionListener(new
* ActionListener() { public void actionPerformed(ActionEvent e) { MoviesFrame
* m=new MoviesFrame(); m.setVisible(true); if(m.isVisible()) { //use to display
* only one screen Main_HomePage.this.dispose(); } } }); btnMovies.setBounds(27,
* 41, 89, 23); panel.add(btnMovies);
*
* JButton btnStar = new JButton("Star"); btnStar.addActionListener(new
* ActionListener() { public void actionPerformed(ActionEvent e) { StarsFrame
* s=new StarsFrame(); s.setVisible(true); if(s.isVisible()) { //use to display
* only one screen Main_HomePage.this.dispose(); } } }); btnStar.setBounds(27,
* 90, 89, 23); panel.add(btnStar);
*
* JButton btnRatings = new JButton("Ratings"); btnRatings.addActionListener(new
* ActionListener() { public void actionPerformed(ActionEvent e) { RatingsFrame
* r=new RatingsFrame(); r.setVisible(true); if(r.isVisible()) { //use to
* display only one screen Main_HomePage.this.dispose(); } }
*
* }); btnRatings.setBounds(27, 145, 89, 23); panel.add(btnRatings);
*
* JButton btnLogout = new JButton("Logout"); btnLogout.addActionListener(new
* ActionListener() { public void actionPerformed(ActionEvent e) { LoginFrame
* lf=new LoginFrame(); lf.setVisible(true); if(lf.isVisible()) { //use to
* display only one screen Main_HomePage.this.dispose(); } } });
* btnLogout.setBounds(27, 198, 89, 23); panel.add(btnLogout); } public void
* selectMovie() {
*
* }
*
* public void viewStar() {
*
* }
*
* public void giveRatings() {
*
* } }
*/
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -79,6 +151,13 @@ public class Main_HomePage extends JFrame {
// and a button // and a button
// on clicking the button, it should call Database.findMovieId(title) // on clicking the button, it should call Database.findMovieId(title)
// and display the movie id if found, or else an error message // and display the movie id if found, or else an error message
//to display ShowMovieFrame
ShowMovieFrame sm=new ShowMovieFrame();
sm.setVisible(true);
if(sm.isVisible()) {
//use to display only one screen
Main_HomePage.this.dispose();
}
} }
}); });
@ -154,3 +233,5 @@ public class Main_HomePage extends JFrame {
panel.add(btnLogout); panel.add(btnLogout);
} }
} }

77
Favorite_Movies/src/ShowMovieFrame.java

@ -0,0 +1,77 @@
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 java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class ShowMovieFrame extends JFrame {
private JPanel contentPane;
private JTextField tf_mt_sm;
Database db=new Database();
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ShowMovieFrame frame = new ShowMovieFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public ShowMovieFrame() {
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 Movie Title:");
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_mt_sm = new JTextField();
tf_mt_sm.setBounds(66, 129, 210, 24);
contentPane.add(tf_mt_sm);
tf_mt_sm.setColumns(10);
JButton btnOkSM = new JButton("ok");
btnOkSM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int found = db.findMovieId(tf_mt_sm.getText());
if(found==1) {
JOptionPane.showMessageDialog(null, "Title Found!");
}
else {
JOptionPane.showMessageDialog(null, "Title not found !!");
}
}
});
btnOkSM.setBounds(68, 200, 89, 23);
contentPane.add(btnOkSM);
}
}
Loading…
Cancel
Save