import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.*;

public class Cinema extends JFrame
{
private JLabel lblName,lblIC, lblPN, lblPerson, lblTicket, lblTP;
private JTextField txtName, txtIC, txtPN, txtPerson, txtTicket, txtTP;
private JRadioButton rbA, rbB, rbC, rbD, rbE, rbF;
private ButtonGroup radioGroup;
private JCheckBox cbxA1, cbxA2, cbxA3, cbxA4, cbxA5, cbxA6, cbxA7, cbxA8, cbxB1, cbxB2, cbxB3, cbxB4, cbxB5, cbxB6, cbxB7, cbxB8, cbxC1, cbxC2, cbxC3, cbxC4, cbxC5, cbxC6, cbxC7, cbxC8, cbxD1, cbxD2, cbxD3, cbxD4, cbxD5, cbxD6, cbxD7, cbxD8, cbxE1, cbxE2, cbxE3, cbxE4, cbxE5, cbxE6, cbxE7, cbxE8;
private JButton btnCalc, btnClear, btnP, btnExit;
private JPanel pnlMovie, pnl1, pnlSits, pnl2, pnlDetail, pnl3, pnlTicket, pnl4, pnlCalculate, pnlCalc, pnlP, pnlPrint;

public Cinema()
{
super ("Movie Cinema");
Container cont = getContentPane();

lblName = new JLabel ("Customer Name : ");
lblIC = new JLabel ("IC Number. : ");
lblPN = new JLabel ("Phone Number : ");
lblTicket = new JLabel ("Ticket Price : ");
lblPerson = new JLabel ("Number Of Person : ");
lblTP = new JLabel ("Total Price : ");

txtName = new JTextField (10);
txtIC = new JTextField (10);
txtPN = new JTextField (10);
txtTicket = new JTextField (7);
txtTicket.setEditable(false);
txtPerson = new JTextField (3);
txtPerson.setEditable(false);
txtTP = new JTextField (7);
txtTP.setEditable(false);

rbA = new JRadioButton("Karate Kid");
rbB = new JRadioButton("Terminator 3");
rbC = new JRadioButton("The Fast And The Furious");
rbD = new JRadioButton("MR & MRS Smith");
rbE = new JRadioButton("Universal Soldier");
rbF = new JRadioButton("Night At The Museum");
radioGroup = new ButtonGroup();
radioGroup.add(rbA);
radioGroup.add(rbB);
radioGroup.add(rbC);
radioGroup.add(rbD);
radioGroup.add(rbE);
radioGroup.add(rbF);

cbxA1 = new JCheckBox ("A-1");
cbxA2 = new JCheckBox ("A-2");
cbxA3 = new JCheckBox ("A-3");

btnCalc = new JButton("Calculate");
btnClear = new JButton("Clear");
btnP = new JButton("Print");
btnExit = new JButton("Exit");

pnlMovie = new JPanel();
pnlMovie.setLayout(new GridLayout(1, 1));
pnlMovie.setBorder(new TitledBorder(new EtchedBorder(),("Type Of Movies")));

pnl1 = new JPanel();
pnl1.setLayout(new GridLayout(2, 3));

pnlSits = new JPanel();
pnlSits.setLayout(new GridLayout(1, 1));
pnlSits.setBorder(new TitledBorder(new EtchedBorder(),("Please Choose Your Sits")));

pnl2 = new JPanel();
pnl2.setLayout(new GridLayout(5, 8));

pnlDetail = new JPanel();
pnlDetail.setLayout(new GridLayout(1, 1));
pnlDetail.setBorder(new TitledBorder(new EtchedBorder(),("Fill In Your Details")));

pnl3 = new JPanel();
pnl3.setLayout(new GridLayout(3, 2));

pnlTicket = new JPanel();
pnlTicket.setLayout(new GridLayout(1, 1));
pnlTicket.setBorder(new TitledBorder(new EtchedBorder(),("Ticket Details")));

pnl4 = new JPanel();
pnl4.setLayout(new GridLayout(4,2));

pnlP = new JPanel();
pnlP.setLayout(new FlowLayout());
pnlP.setBorder(new TitledBorder(new EtchedBorder(),("Print ticket")));

pnlPrint = new JPanel();
pnlPrint.setLayout(new FlowLayout());

pnlMovie.add(pnl1);
pnlSits.add(pnl2);
pnlDetail.add(pnl3);
pnlTicket.add(pnl4);
pnlP.add(pnlPrint);

pnl1.add(rbA);
pnl1.add(rbB);
pnl1.add(rbC);
pnl1.add(rbD);
pnl1.add(rbE);
pnl1.add(rbF);

pnl2.add(cbxA1);
pnl2.add(cbxA2);
pnl2.add(cbxA3);

pnl3.add(lblName);
pnl3.add(txtName);
pnl3.add(lblIC);
pnl3.add(txtIC);
pnl3.add(lblPN);
pnl3.add(txtPN);

pnl4.add(lblPerson);
pnl4.add(txtPerson);
pnl4.add(lblTicket);
pnl4.add(txtTicket);
pnl4.add(lblTicket);
pnl4.add(txtTicket);

pnl4.add(btnCalc);
pnl4.add(btnClear);

pnlP.add(btnP);
pnlP.add(btnExit);

cont.add(pnlMovie, BorderLayout.NORTH);
cont.add(pnlSits, BorderLayout.WEST);
cont.add(pnlDetail, BorderLayout.CENTER);
cont.add(pnlTicket, BorderLayout.EAST);
cont.add(pnlP, BorderLayout.SOUTH);

pcHandler shop = new pcHandler();
btnCalc.addActionListener(shop);
btnClear.addActionListener(shop);
btnP.addActionListener(shop);
btnExit.addActionListener(shop);
setSize (1084, 284);
setVisible(true);
}

private class pcHandler implements ActionListener
{
public void actionPerformed(ActionEvent arie)
{
if(arie.getSource() == btnCalc)
{
double total = 0.0;
double price = 0.0;
int person = 0;

if(rbA.isSelected())
{
if(cbxA1.isSelected())
{
price = 5.00;
sit = 1;
}
else if(cbxA2.isSelected())
{
price = 5.00;
sit = 1;
}
else if(cbxA3.isSelected())
{
price = 5.00;
sit = 1;
}
}
if(rbB.isSelected())
{
if(cbxA1.isSelected())
{
price = 6.00;
sit = 1;
}
else if(cbxA2.isSelected())
{
price = 6.00;
sit = 1;
}
else if(cbxA3.isSelected())
{
price = 6.00;
sit = 1;
}
}
if(rbC.isSelected())
{
if(cbxA1.isSelected())
{
price = 7.00;
sit = 1;
}
else if(cbxA2.isSelected())
{
price = 7.00;
sit = 1;
}
else if(cbxA3.isSelected())
{
price = 7.00;
sit = 1;
}
}
if(rbD.isSelected())
{
if(cbxA1.isSelected())
{
price = 8.00;
sit = 1;
}
else if(cbxA2.isSelected())
{
price = 8.00;
sit = 1;
}
else if(cbxA3.isSelected())
{
price = 8.00;
sit = 1;
}
}
if(rbE.isSelected())
{
if(cbxA1.isSelected())
{
price = 6.00;
sit = 1;
}
else if(cbxA2.isSelected())
{
price = 6.00;
sit = 1;
}
else if(cbxA3.isSelected())
{
price = 6.00;
sit = 1;
}
}
if(rbF.isSelected())
{
if(cbxA1.isSelected())
{
price = 5.00;
sit = 1;
}
else if(cbxA2.isSelected())
{
price = 5.00;
sit = 1;
}
else if(cbxA3.isSelected())
{
price = 5.00;
sit = 1;
}
}
total = price * person;
txtTicket.setText("RM "+ price);
txtPerson.setText(" "+ person);
txtTP.setText("RM "+ total);
}
else if (a.getSource() == btnClear)
{
txtName.setText(" ");
txtIC.setText(" ");
txtPN.setText(" ");
txtTicket.setText(" ");
txtPerson.setText(" ");
}
else if(a.getSource() == btnP)
{
System.out.println("Name : "+txtName.getText()+"\n\nIC Number : "+txtIC.getText()+"\n\nTicket Price : "+txtTicket.getText()+"\n\nNo.Of Person : "+txtPerson.getText());
System.out.println();
System.out.println("Sits Number : "+cbxA1.getText()+cbxA2.getText()+cbxA3.getText()+cbxA4.getText()+cbxA5.getText()+cbxA6.getText()+cbxA7.getText()+cbxA8.getText()+cbxB1.getText()+cbxB2.getText()+cbxB3.getText()+cbxB4.getText()+cbxB5.getText()+cbxB6.getText()+cbxB7.getText()+cbxB8.getText()+cbxC1.getText()+cbxC2.getText()+cbxC3.getText()+cbxC4.getText()+cbxC5.getText()+cbxC6.getText()+cbxC7.getText()+cbxC8.getText()+cbxD1.getText()+cbxD2.getText()+cbxD3.getText()+cbxD4.getText()+cbxD5.getText()+cbxD6.getText()+cbxD7.getText()+cbxD8.getText()+cbxE1.getText()+cbxE2.getText()+cbxE3.getText()+cbxE4.getText()+cbxE5.getText()+cbxE6.getText()+cbxE7.getText()+cbxE8.getText());
System.out.println();
System.out.println("Please show this ticket on the way in");
}
else

System.exit(0);
}
}
public static void main(String[] args)
{
Cinema c = new Cinema();
c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

No information about what is wrong, no information on how you expect it to work, no problem description, no code tags, Well I guess someone will have to use a crystal ball to help you out here.

we can add "no indentation" to that as well. Stephen: have you upgraded your crystal ball to 1.6u22 yet? I hear that there are problems with temporal leakage in the future vision support.

No information about what is wrong, no information on how you expect it to work, no problem description, no code tags, Well I guess someone will have to use a crystal ball to help you out here.

owh sorry sir....i'm using java...the problem is i can't execute it..what i'm expecting for is when we click at the checkbox, it will give the value at the text number of person. then, when we click at the movie's name, it will automatically give the value to ticket price. and when we click the button calculate, it will give the total price of person * ticket price..can u help me?

we can add "no indentation" to that as well. Stephen: have you upgraded your crystal ball to 1.6u22 yet? I hear that there are problems with temporal leakage in the future vision support.

The lack of indentation is an inevitable result of the lack of code tags. html renderers by protocol will strip all leading whitespace (thus all indentation) from strings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.