7 changed files with 757 additions and 0 deletions
Split View
Diff Options
-
298Favorite_Movies/src/MoviesFrame.java
-
200Favorite_Movies/src/RatingsFrame.java
-
8Favorite_Movies/src/ReadMe.txt
-
248Favorite_Movies/src/StarsFrame.java
-
1Favorite_Movies/src/files/data.txt
-
1Favorite_Movies/src/files/ratings_data.txt
-
1Favorite_Movies/src/files/star_data.txt
@ -0,0 +1,298 @@ |
|||
|
|||
/* |
|||
* import java.awt.BorderLayout; import java.awt.EventQueue; |
|||
* |
|||
* import javax.swing.JFrame; import javax.swing.JPanel; import |
|||
* javax.swing.JTextField; import javax.swing.border.EmptyBorder; import |
|||
* javax.swing.table.DefaultTableModel; import javax.swing.table.TableRowSorter; |
|||
* |
|||
* import java.awt.Color; import javax.swing.JLabel; import |
|||
* javax.swing.JOptionPane; |
|||
* |
|||
* import java.awt.Font; import javax.swing.JButton; import |
|||
* java.awt.event.ActionListener; import java.io.FileWriter; import |
|||
* java.io.IOException; import java.awt.event.ActionEvent; import |
|||
* java.awt.TextField; import java.io.FileReader; import java.io.FileWriter; |
|||
* import java.io.Writer; |
|||
* |
|||
* |
|||
* public class Movies extends JFrame { |
|||
* |
|||
* private JPanel contentPane; private JTextField tf_mid; private JTextField |
|||
* tf_title; private JTextField tf_year; private JTextField tf_sname; private |
|||
* JTextField tf_length; private JTextField tf_genre ; private JTextField |
|||
* tf_pname; private JTextField tf_shortDesc; private JTextField tf_avgrate; |
|||
* private JTextField tf_num_watch; |
|||
* |
|||
*//** |
|||
* Launch the application. |
|||
*/ |
|||
/* |
|||
* public static void main(String[] args) { EventQueue.invokeLater(new |
|||
* Runnable() { public void run() { try { Movies frame = new Movies(); |
|||
* frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); |
|||
* } |
|||
* |
|||
*/ |
|||
|
|||
|
|||
|
|||
import java.awt.BorderLayout; |
|||
import java.awt.EventQueue; |
|||
|
|||
import javax.swing.JFrame; |
|||
import javax.swing.JPanel; |
|||
import javax.swing.JTextField; |
|||
import javax.swing.border.EmptyBorder; |
|||
import javax.swing.table.DefaultTableModel; |
|||
import javax.swing.table.TableRowSorter; |
|||
|
|||
import java.awt.Color; |
|||
import javax.swing.JLabel; |
|||
import javax.swing.JOptionPane; |
|||
|
|||
import java.awt.Font; |
|||
import javax.swing.JButton; |
|||
import java.awt.event.ActionListener; |
|||
import java.io.FileWriter; |
|||
import java.io.IOException; |
|||
import java.awt.event.ActionEvent; |
|||
import java.awt.TextField; |
|||
import java.io.FileReader; |
|||
import java.io.FileWriter; |
|||
import java.io.Writer; |
|||
|
|||
public class MoviesFrame extends JFrame{ |
|||
|
|||
|
|||
private JPanel contentPane; |
|||
private JTextField tf_mid; |
|||
private JTextField tf_title; |
|||
private JTextField tf_year; |
|||
private JTextField tf_sname; |
|||
private JTextField tf_length; |
|||
private JTextField tf_genre ; |
|||
private JTextField tf_pname; |
|||
private JTextField tf_shortDesc; |
|||
private JTextField tf_avgrate; |
|||
private JTextField tf_num_watch; |
|||
|
|||
Movies mv=new Movies(); |
|||
|
|||
|
|||
public static void main(String[] args) { |
|||
EventQueue.invokeLater(new Runnable() { |
|||
public void run() { |
|||
try { |
|||
MoviesFrame frame = new MoviesFrame(); |
|||
frame.setVisible(true); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* Create the frame. |
|||
*/ |
|||
public MoviesFrame() { |
|||
|
|||
//Object[] cols={"Movie ID","Title","Year","Length","Genre","Studio Name","Producer Name","Short Description","Avg Ratings","Num Watched"}; |
|||
Object[] rows = new Object[10] ; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|||
setBounds(100,100, 837, 639); |
|||
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(10, 11, 801, 578); |
|||
contentPane.add(panel); |
|||
panel.setLayout(null); |
|||
|
|||
|
|||
|
|||
JLabel lblNewLabel = new JLabel("Movie Details"); |
|||
lblNewLabel.setBounds(273,11, 160, 29); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 24)); |
|||
lblNewLabel.setForeground(new Color(255, 255, 255)); panel.add(lblNewLabel); |
|||
|
|||
JLabel lblNewLabel_1 = new JLabel("Movie Id:"); |
|||
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1.setForeground(Color.WHITE); |
|||
lblNewLabel_1.setBounds(31, 74, 109, 14); |
|||
panel.add(lblNewLabel_1); |
|||
|
|||
JLabel lblNewLabel_1_1 = new JLabel("Title:"); |
|||
lblNewLabel_1_1.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_1.setForeground(Color.WHITE); |
|||
lblNewLabel_1_1.setBounds(31, 110, 46, 14); |
|||
panel.add(lblNewLabel_1_1); |
|||
|
|||
JLabel lblNewLabel_1_2 = new JLabel("Year:"); |
|||
lblNewLabel_1_2.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_2.setForeground(Color.WHITE); |
|||
lblNewLabel_1_2.setBounds(31, 151, 46, 14); |
|||
panel.add(lblNewLabel_1_2); |
|||
|
|||
JLabel lblNewLabel_1_3 = new JLabel("Length:"); |
|||
lblNewLabel_1_3.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3.setBounds(31, 187, 89, 23); |
|||
panel.add(lblNewLabel_1_3); |
|||
|
|||
JLabel lblNewLabel_1_3_1 = new JLabel("Genre:"); |
|||
lblNewLabel_1_3_1.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3_1.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3_1.setBounds(31, 233, 89,23); |
|||
panel.add(lblNewLabel_1_3_1); |
|||
|
|||
JLabel lblNewLabel_1_3_2 = new JLabel("Studio Name:"); |
|||
lblNewLabel_1_3_2.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3_2.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3_2.setBounds(31, 281, 109,23); |
|||
panel.add(lblNewLabel_1_3_2); |
|||
|
|||
JLabel lblNewLabel_1_3_3 = new JLabel("Producer Name:"); |
|||
lblNewLabel_1_3_3.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3_3.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3_3.setBounds(31, 328, 127,23); |
|||
panel.add(lblNewLabel_1_3_3); |
|||
|
|||
JLabel lblNewLabel_1_3_4 = new JLabel("Short Description :"); |
|||
lblNewLabel_1_3_4.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3_4.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3_4.setBounds(31, 374, 149,23); |
|||
panel.add(lblNewLabel_1_3_4); |
|||
|
|||
JLabel lblNewLabel_1_3_5 = new JLabel("Avg. Ratings:"); |
|||
lblNewLabel_1_3_5.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3_5.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3_5.setBounds(31, 424, 127,23); |
|||
panel.add(lblNewLabel_1_3_5); |
|||
|
|||
JLabel lblNewLabel_1_3_6 = new JLabel("Num. Watched :"); |
|||
lblNewLabel_1_3_6.setForeground(Color.WHITE); |
|||
lblNewLabel_1_3_6.setFont(new Font("Tahoma", Font.PLAIN, 14)); |
|||
lblNewLabel_1_3_6.setBounds(31, 479, 127,23); |
|||
panel.add(lblNewLabel_1_3_6); |
|||
|
|||
tf_mid = new JTextField(); tf_mid.setBounds(231, 66, 222, 29); |
|||
panel.add(tf_mid); |
|||
|
|||
tf_title = new JTextField(); tf_title.setBounds(231, 110, 222, 29); |
|||
panel.add(tf_title); |
|||
|
|||
tf_year = new JTextField(); tf_year.setBounds(231, 151, 222, 29); |
|||
panel.add(tf_year); |
|||
|
|||
tf_length = new JTextField(); tf_length.setBounds(231, 187, 222, 29); |
|||
panel.add(tf_length); |
|||
|
|||
tf_genre = new JTextField(); tf_genre.setBounds(231, 233, 222, 29); |
|||
panel.add(tf_genre); |
|||
|
|||
tf_sname = new JTextField(); tf_sname.setBounds(231, 281, 222, 29); |
|||
panel.add(tf_sname); |
|||
|
|||
tf_pname = new JTextField(); tf_pname.setBounds(231, 328, 222, 29); |
|||
panel.add(tf_pname); |
|||
|
|||
tf_shortDesc = new JTextField(); tf_shortDesc.setBounds(231, 378, 222, 29); |
|||
panel.add(tf_shortDesc); |
|||
|
|||
tf_avgrate = new JTextField(); tf_avgrate.setBounds(231, 424, 222, 29); |
|||
panel.add(tf_avgrate); |
|||
|
|||
tf_num_watch = new JTextField(); tf_num_watch.setBounds(231, 479, 222, 29); |
|||
panel.add(tf_num_watch); |
|||
|
|||
JLabel lblNewLabel_2 = new JLabel("Poster"); |
|||
lblNewLabel_2.setForeground(new Color(255, 255, 255)); |
|||
lblNewLabel_2.setBounds(549, 74, 222, 188); |
|||
panel.add(lblNewLabel_2); |
|||
|
|||
JButton btnHomeM = new JButton("Home"); |
|||
btnHomeM.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
Main_HomePage mhp=new Main_HomePage(); mhp.setVisible(true); |
|||
if(mhp.isVisible()) { |
|||
//use to display only one screen |
|||
MoviesFrame.this.dispose(); } } }); |
|||
btnHomeM.setBounds(425, 538, 89, 23); |
|||
panel.add(btnHomeM); |
|||
|
|||
JButton btnM_ok = new JButton("OK"); |
|||
btnM_ok.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
if(tf_mid.getText().isEmpty() || tf_title.getText().isEmpty() ||tf_year.getText().isEmpty() || tf_genre.getText().isEmpty()||tf_num_watch.getText().isEmpty() || tf_avgrate.getText().isEmpty() ||tf_pname.getText().isEmpty() || tf_sname.getText().isEmpty() ||tf_shortDesc.getText().isEmpty() || tf_length.getText().isEmpty()) { |
|||
|
|||
JOptionPane.showMessageDialog(null, "Please Enter All the Fields !!"); |
|||
} |
|||
else{ |
|||
|
|||
mv.setMovieId(Integer.parseInt(tf_mid.getText())); |
|||
mv.setTitle(tf_title.getText()); |
|||
mv.setLength(Integer.parseInt(tf_length.getText())); |
|||
mv.setYear(Integer.parseInt(tf_year.getText())); |
|||
mv.setGenre(tf_genre.getText()); |
|||
mv.setStudioName(tf_sname.getText()); |
|||
mv.setProducerName(tf_pname.getText()); |
|||
mv.setShortDescription(tf_shortDesc.getText()); |
|||
mv.setAvgRating(Double.parseDouble(tf_avgrate.getText())); |
|||
mv.setNumWatched(Integer.parseInt(tf_num_watch.getText())); |
|||
|
|||
/* |
|||
* rows[0] = tf_mid.getText(); rows[1] = tf_title.getText(); rows[2] = |
|||
* tf_year.getText(); rows[3] = tf_length.getText(); rows[4] = |
|||
* tf_genre.getText(); rows[5] = tf_sname.getText(); rows[6] = |
|||
* tf_pname.getText(); rows[7] = tf_shortDesc.getText(); rows[8] = |
|||
* tf_avgrate.getText(); rows[9] = tf_num_watch.getText(); |
|||
*/ |
|||
//model.addRow(rows); |
|||
|
|||
try { |
|||
|
|||
FileWriter fw = new FileWriter( "C:\\Users\\skc\\eclipse-workspace\\first\\Favorite_Movies\\src\\files\\data.txt",true); |
|||
tf_mid.write(fw); |
|||
tf_title.write(fw.append(" ")); |
|||
tf_year.write(fw.append(" ")); |
|||
tf_length.write(fw.append(" ")); |
|||
tf_genre.write(fw.append(" ")); |
|||
tf_sname.write(fw.append(" ")); |
|||
tf_pname.write(fw.append(" ")); |
|||
tf_shortDesc.write(fw.append(" ")); |
|||
tf_avgrate.write(fw.append(" ")); |
|||
tf_num_watch.write(fw.append(" ")); |
|||
fw.write("\n"); |
|||
|
|||
fw.close(); |
|||
|
|||
JOptionPane.showMessageDialog(null, "Movie added Successfully....."); |
|||
|
|||
tf_mid.setText(""); |
|||
tf_title.setText(""); |
|||
tf_year.setText(""); tf_length.setText(""); tf_genre.setText(""); |
|||
tf_sname.setText(""); tf_pname.setText(""); tf_shortDesc.setText(""); |
|||
tf_avgrate.setText(""); tf_num_watch.setText(""); |
|||
|
|||
} catch (IOException e1) { // TODO Auto-generated catch block |
|||
e1.printStackTrace(); } |
|||
|
|||
} |
|||
|
|||
} |
|||
}); |
|||
btnM_ok.setBounds(281, 538, 89, 23); panel.add(btnM_ok); |
|||
} |
|||
public void addMovie(MoviesFrame mf) { |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,200 @@ |
|||
|
|||
|
|||
/* |
|||
* 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.JTextField; import |
|||
* javax.swing.JButton; import java.awt.Font; import javax.swing.SwingConstants; |
|||
* import java.awt.event.ActionListener; import java.awt.event.ActionEvent; |
|||
* |
|||
* public class Ratings extends JFrame { |
|||
* |
|||
* private JPanel contentPane; private JTextField textField; private JTextField |
|||
* textField_1; private JTextField textField_2; private JTextField textField_3; |
|||
* |
|||
*//** |
|||
* Launch the application. |
|||
*/ |
|||
|
|||
/* public static void main(String[] args) { EventQueue.invokeLater(new |
|||
Runnable() { public void run() { try { Ratings frame = new Ratings(); |
|||
frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); |
|||
}*/ |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
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 javax.swing.JTextField; |
|||
import javax.swing.JButton; |
|||
import java.awt.Font; |
|||
import javax.swing.SwingConstants; |
|||
import java.awt.event.ActionListener; |
|||
import java.io.FileWriter; |
|||
import java.io.IOException; |
|||
import java.awt.event.ActionEvent; |
|||
|
|||
public class RatingsFrame extends JFrame { |
|||
|
|||
|
|||
|
|||
Ratings r=new Ratings(); |
|||
|
|||
private JPanel contentPane; |
|||
private JTextField tf_midR; |
|||
private JTextField tf_snameR; |
|||
private JTextField tf_relationR; |
|||
private JTextField tf_ratingsR; |
|||
|
|||
Ratings rt=new Ratings(); |
|||
|
|||
|
|||
public static void main(String[] args) { |
|||
EventQueue.invokeLater(new Runnable() { |
|||
public void run() { |
|||
try { |
|||
RatingsFrame frame = new RatingsFrame(); |
|||
frame.setVisible(true); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* Create the frame. |
|||
*/ |
|||
public RatingsFrame() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|||
setBounds(100, 100, 589, 488); contentPane = new JPanel(); |
|||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|||
contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); |
|||
|
|||
JPanel panel = new JPanel(); |
|||
panel.setBackground(new Color(0, 0, 51)); |
|||
contentPane.add(panel, BorderLayout.CENTER); |
|||
panel.setLayout(null); |
|||
|
|||
JLabel lblNewLabel = new JLabel("Ratings Details"); |
|||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 24)); |
|||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); |
|||
lblNewLabel.setForeground(new Color(255, 255, 255)); |
|||
lblNewLabel.setBounds(148, 22, 247, 36); panel.add(lblNewLabel); |
|||
|
|||
JLabel lblNewLabel_1 = new JLabel("Movie ID:"); |
|||
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
lblNewLabel_1.setForeground(new Color(255,255, 255)); |
|||
lblNewLabel_1.setBounds(41, 87, 76, 14); |
|||
panel.add(lblNewLabel_1); |
|||
|
|||
JLabel lblNewLabel_2 = new JLabel("Name Surname:"); |
|||
lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
lblNewLabel_2.setForeground(new Color(255,255, 255)); |
|||
lblNewLabel_2.setBounds(41, 129, 127, 36); |
|||
panel.add(lblNewLabel_2); |
|||
|
|||
JLabel lblNewLabel_3 = new JLabel("Relation:"); |
|||
lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
lblNewLabel_3.setForeground(new Color(255,255, 255)); |
|||
lblNewLabel_3.setBounds(41, 183, 76, 36); |
|||
panel.add(lblNewLabel_3); |
|||
|
|||
JLabel lblNewLabel_4 = new JLabel("Ratings :"); |
|||
lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
lblNewLabel_4.setForeground(new Color(255,255, 255)); |
|||
lblNewLabel_4.setBounds(41, 245, 76, 17); |
|||
|
|||
panel.add(lblNewLabel_4); |
|||
|
|||
tf_midR = new JTextField(); tf_midR.setBounds(194, 86, 183, 20); |
|||
panel.add(tf_midR); |
|||
tf_midR.setColumns(10); |
|||
|
|||
tf_snameR = new JTextField(); tf_snameR.setColumns(10); |
|||
tf_snameR.setBounds(194, 139, 179, 20); panel.add(tf_snameR); |
|||
|
|||
tf_relationR = new JTextField(); tf_relationR.setColumns(10); |
|||
tf_relationR.setBounds(194, 193, 179, 20); panel.add(tf_relationR); |
|||
|
|||
tf_ratingsR = new JTextField(); tf_ratingsR.setColumns(10); |
|||
tf_ratingsR.setBounds(194, 245, 183, 20); |
|||
panel.add(tf_ratingsR); |
|||
|
|||
JButton btnaddR = new JButton("OK"); |
|||
btnaddR.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
if(tf_midR.getText().isEmpty() || tf_relationR.getText().isEmpty() ||tf_ratingsR.getText().isEmpty() || tf_snameR.getText().isEmpty()) { |
|||
|
|||
JOptionPane.showMessageDialog(null, "Please Enter All the Fields !!"); |
|||
} |
|||
else{ |
|||
rt.setMovieId(Integer.parseInt(tf_midR.getText())); |
|||
rt.setRelation(tf_relationR.getText()); |
|||
rt.setNameSurname(tf_snameR.getText()); |
|||
rt.setRating(Integer.parseInt(tf_ratingsR.getText())); |
|||
|
|||
try { |
|||
|
|||
FileWriter fw = new FileWriter( "C:\\Users\\skc\\eclipse-workspace\\first\\Favorite_Movies\\src\\files\\ratings_data.txt",true); |
|||
tf_midR.write(fw); |
|||
tf_snameR.write(fw.append(" ")); |
|||
tf_relationR.write(fw.append(" ")); |
|||
tf_ratingsR.write(fw.append(" ")); |
|||
|
|||
fw.write("\n"); |
|||
|
|||
fw.close(); |
|||
|
|||
JOptionPane.showMessageDialog(null, "Ratings added Successfully....."); |
|||
|
|||
tf_midR.setText(""); |
|||
tf_relationR.setText(""); |
|||
tf_ratingsR.setText(""); |
|||
tf_snameR.setText(""); |
|||
|
|||
} catch (IOException e1) { // TODO Auto-generated catch block |
|||
e1.printStackTrace(); } |
|||
} |
|||
} |
|||
}); |
|||
btnaddR.setBounds(195, 320,89, 23); panel.add(btnaddR); |
|||
|
|||
JButton btnHomeR = new JButton("Home"); |
|||
btnHomeR.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
Main_HomePage mhp=new Main_HomePage(); |
|||
mhp.setVisible(true); |
|||
if(mhp.isVisible()) { //use to display only one screen |
|||
RatingsFrame.this.dispose(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
}); |
|||
|
|||
btnHomeR.setBounds(304, 320, 89, 23); |
|||
panel.add(btnHomeR); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,8 @@ |
|||
I have added 3 java files namely |
|||
MoviesFrame.java |
|||
StarsFrame.java |
|||
RatingsFrame.java |
|||
|
|||
also added text files in the files folder of 4 files |
|||
|
|||
in java file have set values for setter methods for all 3 modules and all 3 modules data will be saved in text files respectively |
|||
@ -0,0 +1,248 @@ |
|||
|
|||
|
|||
|
|||
/* |
|||
* 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.SwingConstants; |
|||
* import javax.swing.JTextField; import javax.swing.JButton; import |
|||
* java.awt.event.ActionListener; import java.awt.event.ActionEvent; |
|||
* |
|||
* public class Star extends JFrame { |
|||
* |
|||
* private JPanel contentPane; private JTextField textField; private JTextField |
|||
* textField_1; private JTextField textField_2; private JTextField textField_3; |
|||
* |
|||
*//** |
|||
* Launch the application. |
|||
*/ |
|||
/* |
|||
* public static void main(String[] args) { EventQueue.invokeLater(new |
|||
* Runnable() { public void run() { try { Star frame = new Star(); |
|||
* frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); |
|||
* } |
|||
* |
|||
*//** |
|||
* Create the frame. |
|||
*//* |
|||
* public Star() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|||
* setBounds(100, 100, 580, 413); contentPane = new JPanel(); |
|||
* contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new |
|||
* BorderLayout(0, 0)); setContentPane(contentPane); |
|||
* |
|||
* JPanel panel = new JPanel(); panel.setBackground(new Color(0, 0, 51)); |
|||
* contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(null); |
|||
* |
|||
* JLabel lblStardetails = new JLabel("Star Details"); |
|||
* lblStardetails.setBounds(148, 22, 247, 36); |
|||
* lblStardetails.setHorizontalAlignment(SwingConstants.CENTER); |
|||
* lblStardetails.setForeground(Color.WHITE); lblStardetails.setFont(new |
|||
* Font("Tahoma", Font.BOLD, 24)); panel.add(lblStardetails); |
|||
* |
|||
* JLabel lblNewLabel_1 = new JLabel("Movie ID:"); lblNewLabel_1.setBounds(41, |
|||
* 87, 76, 14); lblNewLabel_1.setForeground(Color.WHITE); |
|||
* lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
* panel.add(lblNewLabel_1); |
|||
* |
|||
* JLabel lblNewLabel_2 = new JLabel("Name Surname:"); |
|||
* lblNewLabel_2.setBounds(41, 129, 127, 36); |
|||
* lblNewLabel_2.setForeground(Color.WHITE); lblNewLabel_2.setFont(new |
|||
* Font("Tahoma", Font.PLAIN, 16)); panel.add(lblNewLabel_2); |
|||
* |
|||
* JLabel lblNewLabel_3 = new JLabel("Movie Title:"); |
|||
* lblNewLabel_3.setBounds(41, 183, 103, 36); |
|||
* lblNewLabel_3.setForeground(Color.WHITE); lblNewLabel_3.setFont(new |
|||
* Font("Tahoma", Font.PLAIN, 16)); panel.add(lblNewLabel_3); |
|||
* |
|||
* JLabel lblNewLabel_4 = new JLabel("Movie Year:"); lblNewLabel_4.setBounds(41, |
|||
* 245, 103, 17); lblNewLabel_4.setForeground(Color.WHITE); |
|||
* lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
* panel.add(lblNewLabel_4); |
|||
* |
|||
* textField = new JTextField(); textField.setBounds(194, 86, 183, 20); |
|||
* textField.setColumns(10); panel.add(textField); |
|||
* |
|||
* textField_1 = new JTextField(); textField_1.setBounds(194, 139, 179, 20); |
|||
* textField_1.setColumns(10); panel.add(textField_1); |
|||
* |
|||
* textField_2 = new JTextField(); textField_2.setBounds(194, 193, 179, 20); |
|||
* textField_2.setColumns(10); panel.add(textField_2); |
|||
* |
|||
* textField_3 = new JTextField(); textField_3.setBounds(194, 245, 183, 20); |
|||
* textField_3.setColumns(10); panel.add(textField_3); |
|||
* |
|||
* JButton btnStar = new JButton("OK"); btnStar.setBounds(195, 320, 89, 23); |
|||
* panel.add(btnStar); |
|||
* |
|||
* JButton btnHome = new JButton("Home"); btnHome.addActionListener(new |
|||
* ActionListener() { public void actionPerformed(ActionEvent e) { Main_HomePage |
|||
* mhp=new Main_HomePage(); mhp.setVisible(true); if(mhp.isVisible()) { //use to |
|||
* display only one screen Star.this.dispose(); } } }); btnHome.setBounds(306, |
|||
* 320, 89, 23); panel.add(btnHome); } |
|||
* |
|||
* } |
|||
*/ |
|||
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.SwingConstants; |
|||
import javax.swing.JTextField; |
|||
import javax.swing.JButton; |
|||
import java.awt.event.ActionListener; |
|||
import java.io.FileWriter; |
|||
import java.io.IOException; |
|||
import java.awt.event.ActionEvent; |
|||
|
|||
|
|||
public class StarsFrame extends JFrame { |
|||
|
|||
|
|||
|
|||
private JPanel contentPane; |
|||
private JTextField tf_midS; |
|||
private JTextField tf_snameS; |
|||
private JTextField tf_mtitleS; |
|||
private JTextField tf_yearS; |
|||
Star s=new Star(); |
|||
|
|||
/** |
|||
* Create the frame. |
|||
*/ |
|||
|
|||
public static void main(String[] args) { |
|||
EventQueue.invokeLater(new Runnable() { |
|||
public void run() { |
|||
try { |
|||
|
|||
StarsFrame frame = new StarsFrame(); |
|||
frame.setVisible(true); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public StarsFrame() { |
|||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|||
setBounds(100, 100, 580, 413); |
|||
contentPane = new JPanel(); |
|||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|||
contentPane.setLayout(new BorderLayout(0, 0)); |
|||
setContentPane(contentPane); |
|||
|
|||
JPanel panel = new JPanel(); panel.setBackground(new Color(0, 0, 51)); |
|||
contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(null); |
|||
|
|||
JLabel lblStardetails = new JLabel("Star Details"); |
|||
lblStardetails.setBounds(148, 22, 247, 36); |
|||
lblStardetails.setHorizontalAlignment(SwingConstants.CENTER); |
|||
lblStardetails.setForeground(Color.WHITE); lblStardetails.setFont(new |
|||
Font("Tahoma", Font.BOLD, 24)); panel.add(lblStardetails); |
|||
|
|||
JLabel lblNewLabel_1 = new JLabel("Movie ID:"); lblNewLabel_1.setBounds(41, |
|||
87, 76, 14); lblNewLabel_1.setForeground(Color.WHITE); |
|||
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
panel.add(lblNewLabel_1); |
|||
|
|||
JLabel lblNewLabel_2 = new JLabel("Name Surname:"); |
|||
lblNewLabel_2.setBounds(41, 129, 127, 36); |
|||
lblNewLabel_2.setForeground(Color.WHITE); lblNewLabel_2.setFont(new |
|||
Font("Tahoma", Font.PLAIN, 16)); panel.add(lblNewLabel_2); |
|||
|
|||
JLabel lblNewLabel_3 = new JLabel("Movie Title:"); |
|||
lblNewLabel_3.setBounds(41, 183, 103, 36); |
|||
lblNewLabel_3.setForeground(Color.WHITE); lblNewLabel_3.setFont(new |
|||
Font("Tahoma", Font.PLAIN, 16)); panel.add(lblNewLabel_3); |
|||
|
|||
JLabel lblNewLabel_4 = new JLabel("Movie Year:"); lblNewLabel_4.setBounds(41, |
|||
245, 103, 17); lblNewLabel_4.setForeground(Color.WHITE); |
|||
lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 16)); |
|||
panel.add(lblNewLabel_4); |
|||
|
|||
tf_midS = new JTextField(); tf_midS.setBounds(194, 86, 183, 20); |
|||
tf_midS.setColumns(10); panel.add(tf_midS); |
|||
|
|||
tf_snameS = new JTextField(); tf_snameS.setBounds(194, 139, 179, 20); |
|||
tf_snameS.setColumns(10); panel.add(tf_snameS); |
|||
|
|||
tf_mtitleS = new JTextField(); tf_mtitleS.setBounds(194, 193, 179, 20); |
|||
tf_mtitleS.setColumns(10); panel.add(tf_mtitleS); |
|||
|
|||
tf_yearS = new JTextField(); tf_yearS.setBounds(194, 245, 183, 20); |
|||
tf_yearS.setColumns(10); panel.add(tf_yearS); |
|||
|
|||
JButton btnStar = new JButton("OK"); |
|||
btnStar.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
if(tf_midS.getText().isEmpty() || tf_mtitleS.getText().isEmpty() ||tf_yearS.getText().isEmpty() || tf_snameS.getText().isEmpty()) { |
|||
|
|||
JOptionPane.showMessageDialog(null, "Please Enter All the Fields !!"); |
|||
} |
|||
else{ |
|||
s.setMovieId(Integer.parseInt(tf_midS.getText())); |
|||
s.setMovieTitle(tf_mtitleS.getText()); |
|||
s.setNameSurname(tf_snameS.getText()); |
|||
s.setYear(Integer.parseInt(tf_yearS.getText())); |
|||
|
|||
try { |
|||
|
|||
FileWriter fw = new FileWriter( "C:\\Users\\skc\\eclipse-workspace\\first\\Favorite_Movies\\src\\files\\star_data.txt",true); |
|||
tf_midS.write(fw); |
|||
tf_mtitleS.write(fw.append(" ")); |
|||
tf_snameS.write(fw.append(" ")); |
|||
tf_yearS.write(fw.append(" ")); |
|||
|
|||
fw.write("\n"); |
|||
|
|||
fw.close(); |
|||
|
|||
JOptionPane.showMessageDialog(null, "Star added Successfully....."); |
|||
|
|||
tf_midS.setText(""); |
|||
tf_mtitleS.setText(""); |
|||
tf_yearS.setText(""); |
|||
tf_snameS.setText(""); |
|||
|
|||
} catch (IOException e1) { // TODO Auto-generated catch block |
|||
e1.printStackTrace(); } |
|||
} |
|||
} |
|||
});btnStar.setBounds(195, 320, 89, 23); |
|||
panel.add(btnStar); |
|||
|
|||
JButton btnHomeS = new JButton("Home"); |
|||
btnHomeS.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
Main_HomePage mhp=new Main_HomePage(); |
|||
mhp.setVisible(true); |
|||
if(mhp.isVisible()) { //use to display only one screen |
|||
StarsFrame.this.dispose(); |
|||
} |
|||
} |
|||
}); |
|||
btnHomeS.setBounds(306,320, 89, 23); |
|||
panel.add(btnHomeS); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,2 +1,3 @@ |
|||
1,finding neemo,2016,01:56,Comic,Disney,sdf,neemo,5.6,2 |
|||
2,Lion King,2016,01:46,Animation,Disney,jk,LK,4.2,3 |
|||
1 gandara 2022 10 melody soju jay song 5.9 5 |
|||
@ -0,0 +1 @@ |
|||
1 jonny son 9 |
|||
@ -0,0 +1 @@ |
|||
1 gandara Jay 2022 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue