I dont know what the problem...seems the button didnt work at all..~
help me find the problem plss...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class listOfMovies extends JFrame implements ActionListener {
private JLabel jlbWelcome, jlbPick;
private JButton jbtBatman, jbtAngels, jbtDue, jbtFaster, jbtFour, jbtHuman, jbtWarrior, jbtWater, jbtHarry;
public listOfMovies () {
JPanel p1 = new JPanel ();
p1.setLayout (new GridLayout (3,3,0,0));
// image icon for buttons
ImageIcon batman = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Batman.jpg");
ImageIcon angels = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Angels.jpg");
ImageIcon due = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\DueDate.jpg");
ImageIcon faster = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\faster.jpg");
ImageIcon four = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Four.jpg");
ImageIcon human = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Human.jpg");
ImageIcon warrior = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Warrior.jpg");
ImageIcon water = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\Water.jpg");
ImageIcon harry = new ImageIcon ("C:\\Users\\User\\Desktop\\OOP project\\img\\icon\\harry.jpg");
// initialize button
jbtBatman = new JButton (batman);
jbtAngels = new JButton (angels);
jbtDue = new JButton (due);
jbtFaster = new JButton (faster);
jbtFour = new JButton (four);
jbtHuman = new JButton (human);
jbtWarrior = new JButton (warrior);
jbtWater = new JButton (water);
jbtHarry = new JButton (harry);
// add button to the frame
p1.add(new JButton(batman));
p1.add(new JButton(angels));
p1.add(new JButton(due));
p1.add(new JButton(faster));
p1.add(new JButton(four));
p1.add(new JButton(human));
p1.add(new JButton(warrior));
p1.add(new JButton(water));
p1.add(new JButton(harry));
// p2 hold welcome label, north
JPanel p2 = new JPanel ();
p2.setLayout (new FlowLayout());
p2.add (jlbWelcome = new JLabel("WELCOME TO MOVIE TICKETING SYSTEM"));
getContentPane().add(p2, BorderLayout.NORTH);
// p3 hold choose movie label, south
JPanel p3 = new JPanel ();
p3.setLayout (new FlowLayout());
p3.add (jlbPick = new JLabel ("Choose Movie"));
getContentPane().add(p3, BorderLayout.SOUTH);
// create scroll bar using scrollpane
JScrollPane scrollpane = new JScrollPane(p1);
getContentPane().add(scrollpane, BorderLayout.CENTER);
jbtBatman.addActionListener(this);
jbtAngels.addActionListener(this);
jbtDue.addActionListener(this);
jbtFaster.addActionListener(this);
jbtFour.addActionListener(this);
jbtHuman.addActionListener(this);
jbtWarrior.addActionListener(this);
jbtWater.addActionListener(this);
jbtHarry.addActionListener(this);
}
public void actionPerformed (ActionEvent e) {
if ((e.getSource() == jbtBatman)) {
bookBatman frame = new bookBatman ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Book Batman : The Dark Knight"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtAngels)) {
bookAngels frame = new bookAngels ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtDue)) {
bookDueDate frame = new bookDueDate ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtFaster)) {
bookFaster frame = new bookFaster ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtFour)) {
bookFour frame = new bookFour ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtHuman)) {
bookHumanTarget frame = new bookHumanTarget ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtWarrior)) {
bookWarrior frame = new bookWarrior ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtWater)) {
bookWater frame = new bookWater ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
if((e.getSource() == jbtHarry)) {
bookHarry frame = new bookHarry ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Booking Movie"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
}
public static void main (String [] args) {
listOfMovies frame=new listOfMovies ();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("List of Movies"); //set title of thewindow
frame.setSize(800,600); //size of the window
frame.setVisible(true); //visible the window
frame.setLocationRelativeTo (null); //center the window
}
}