Hey Guys,
if i want to get the total price in
total = new JTextField(20);
c.add(total);
would i first have to save the price per ticket in a text file and then open that file. Muliplying this then by the number of tickets purchased?.. or is there an easier way?
[CODE=Java]
import java.awt.*;
import java.awt.event. *;
import javax .swing.*;
import java.io.*;
public class Routes extends JFrame implements ActionListener
{
private String from[] = {"From","Cork", "Limerick","Bel fast","Dublin"} ;
private String to[] = {"To","Cork","L imerick","Belfa st","Dublin"} ;
private String tickets[] = {"Tickets","1", "2","3","4","5" ,"6"};
private String back[] = {"Return", "Yes","No"} ;
private JLabel label1, label2, label3,label4;
private JComboBox fromCmb,toCmb, ticketsCmb, backCmb;
private JButton next;
private JLabel Tickets,Price, Total;
private JTextField ticket,price,to tal;
private JButton Procced;
public static void main(String args[])
{
Routes app = new Routes();
}
public Routes() //constructor
{
super("Selec Destinations");
Container c = getContentPane( );
c.setLayout(new FlowLayout());
label1 = new JLabel("From: ");
c.add(label1);
fromCmb = new JComboBox(from) ;
c.add(fromCmb);
label2 = new JLabel("To ");
c.add(label2);
toCmb = new JComboBox(to);
c.add(toCmb);
label3 = new JLabel("Number Of Tickets");
c.add(label3);
ticketsCmb = new JComboBox(ticke ts);
c.add(ticketsCm b);
label4 = new JLabel("Return ");
c.add(label4);
backCmb = new JComboBox(back) ;
c.add(backCmb);
next = new JButton("Next") ;
next.addActionL istener(this);
c.add(next);
Tickets = new JLabel("Number Of Tickets ");
c.add(Tickets);
ticket = new JTextField(20);
c.add(ticket);
Price = new JLabel("Price Per Ticket ");
c.add(Price);
price = new JTextField(20);
c.add(price);
Total = new JLabel("Total ");
c.add(Total);
total = new JTextField(20);
c.add(total);
Procced = new JButton("Procce d");
Procced.addActi onListener(this );
c.add(Procced);
setSize(400, 300);
setVisible(true );
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource() == Procced)
{
Payment payment = new Payment();
setVisible(fals e);
}
}
}[/CODE]
if i want to get the total price in
total = new JTextField(20);
c.add(total);
would i first have to save the price per ticket in a text file and then open that file. Muliplying this then by the number of tickets purchased?.. or is there an easier way?
[CODE=Java]
import java.awt.*;
import java.awt.event. *;
import javax .swing.*;
import java.io.*;
public class Routes extends JFrame implements ActionListener
{
private String from[] = {"From","Cork", "Limerick","Bel fast","Dublin"} ;
private String to[] = {"To","Cork","L imerick","Belfa st","Dublin"} ;
private String tickets[] = {"Tickets","1", "2","3","4","5" ,"6"};
private String back[] = {"Return", "Yes","No"} ;
private JLabel label1, label2, label3,label4;
private JComboBox fromCmb,toCmb, ticketsCmb, backCmb;
private JButton next;
private JLabel Tickets,Price, Total;
private JTextField ticket,price,to tal;
private JButton Procced;
public static void main(String args[])
{
Routes app = new Routes();
}
public Routes() //constructor
{
super("Selec Destinations");
Container c = getContentPane( );
c.setLayout(new FlowLayout());
label1 = new JLabel("From: ");
c.add(label1);
fromCmb = new JComboBox(from) ;
c.add(fromCmb);
label2 = new JLabel("To ");
c.add(label2);
toCmb = new JComboBox(to);
c.add(toCmb);
label3 = new JLabel("Number Of Tickets");
c.add(label3);
ticketsCmb = new JComboBox(ticke ts);
c.add(ticketsCm b);
label4 = new JLabel("Return ");
c.add(label4);
backCmb = new JComboBox(back) ;
c.add(backCmb);
next = new JButton("Next") ;
next.addActionL istener(this);
c.add(next);
Tickets = new JLabel("Number Of Tickets ");
c.add(Tickets);
ticket = new JTextField(20);
c.add(ticket);
Price = new JLabel("Price Per Ticket ");
c.add(Price);
price = new JTextField(20);
c.add(price);
Total = new JLabel("Total ");
c.add(Total);
total = new JTextField(20);
c.add(total);
Procced = new JButton("Procce d");
Procced.addActi onListener(this );
c.add(Procced);
setSize(400, 300);
setVisible(true );
}
public void actionPerformed (ActionEvent e)
{
if (e.getSource() == Procced)
{
Payment payment = new Payment();
setVisible(fals e);
}
}
}[/CODE]
Comment