473,378 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

possible FileInput/output problem

8
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?


Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax .swing.*;
  4. import java.io.*;
  5.  
  6.  
  7. public class Routes extends JFrame implements ActionListener
  8. {
  9.  
  10.     private String from[] = {"From","Cork","Limerick","Belfast","Dublin"};
  11.     private String to[] = {"To","Cork","Limerick","Belfast","Dublin"};
  12.     private String tickets[] = {"Tickets","1","2","3","4","5","6"};
  13.     private String back[] = {"Return", "Yes","No"};
  14.     private JLabel label1, label2, label3,label4;
  15.     private JComboBox fromCmb,toCmb, ticketsCmb, backCmb;
  16.     private JButton next;
  17.     private JLabel Tickets,Price, Total;
  18.     private JTextField ticket,price,total;
  19.     private JButton Procced;
  20.  
  21.  
  22.     public static void main(String args[])
  23.     {
  24.         Routes app = new Routes();
  25.     }
  26.  
  27.     public Routes() //constructor
  28.     {
  29.         super("Selec Destinations");
  30.  
  31.         Container c = getContentPane();
  32.         c.setLayout(new FlowLayout());
  33.  
  34.         label1 = new JLabel("From:          ");
  35.         c.add(label1);
  36.  
  37.         fromCmb = new JComboBox(from);
  38.         c.add(fromCmb);
  39.  
  40.         label2 = new JLabel("To             ");
  41.         c.add(label2);
  42.  
  43.         toCmb = new JComboBox(to);
  44.         c.add(toCmb);
  45.  
  46.         label3 = new JLabel("Number Of Tickets");
  47.         c.add(label3);
  48.  
  49.         ticketsCmb = new JComboBox(tickets);
  50.         c.add(ticketsCmb);
  51.  
  52.         label4 = new JLabel("Return      ");
  53.         c.add(label4);
  54.  
  55.         backCmb = new JComboBox(back);
  56.         c.add(backCmb);
  57.  
  58.         next = new JButton("Next");
  59.         next.addActionListener(this);
  60.         c.add(next);
  61.  
  62.         Tickets = new JLabel("Number Of Tickets ");
  63.         c.add(Tickets);
  64.  
  65.         ticket = new JTextField(20);
  66.         c.add(ticket);
  67.  
  68.         Price = new JLabel("Price Per Ticket     ");
  69.         c.add(Price);
  70.  
  71.         price = new JTextField(20);
  72.         c.add(price);
  73.  
  74.         Total = new JLabel("Total                          ");
  75.         c.add(Total);
  76.  
  77.        total = new JTextField(20);
  78.         c.add(total);
  79.  
  80.         Procced = new JButton("Procced");
  81.         Procced.addActionListener(this);
  82.         c.add(Procced);
  83.  
  84.  
  85.  
  86.         setSize(400, 300);
  87.         setVisible(true);
  88.     }
  89.  
  90.         public void actionPerformed(ActionEvent e)
  91.     {
  92.         if (e.getSource() == Procced)
  93.         {
  94.             Payment payment = new Payment();
  95.             setVisible(false);
  96.         }
  97.     }
  98.  
  99. }
Mar 12 '08 #1
4 1239
BigDaddyLH
1,216 Expert 1GB
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Mar 12 '08 #2
BigDaddyLH
1,216 Expert 1GB
Unless I'm missing something here, you want the user to enter some information in the GUI, then your program should respond by doing a calculation and displaying the result.

I don't see how file I/O is relevant. Am I missing something?

Do you understand how to make GUI's interactive by using listeners? http://java.sun.com/docs/books/tutor...nts/index.html
Mar 12 '08 #3
pleb
8
Unless I'm missing something here, you want the user to enter some information in the GUI, then your program should respond by doing a calculation and displaying the result.

I don't see how file I/O is relevant. Am I missing something?

Do you understand how to make GUI's interactive by using listeners? http://java.sun.com/docs/books/tutor...nts/index.html
Sorry complete newb at this... Yes it will be preforming calculations but the "Admin" have to be able to set/change the ticket prices.. Thus im thinking the Price per ticket has to be read form the text file first?
Mar 12 '08 #4
BigDaddyLH
1,216 Expert 1GB
Sorry complete newb at this... Yes it will be preforming calculations but the "Admin" have to be able to set/change the ticket prices.. Thus im thinking the Price per ticket has to be read form the text file first?
That's certainly possible. One simple way to create configuration data like that is to use a property file:

http://java.sun.com/docs/books/tutor...roperties.html
Mar 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Daniel Yoo | last post by:
Hi everyone, I'm was wondering: would it be a good idea to have the FileInput class support a read() method? I found myself running into a small problem while using xml.sax.parse in combination...
3
by: Chris Connett | last post by:
I just started working with the fileinput module, and reading the bit about inplace modification, it seems very dangerous: From the doc: --- Optional in-place filtering: if the keyword argument...
6
by: cyberco | last post by:
Using fileinput.input('test.txt') I probably forgot to process all lines or so, since I get the error 'input() already active' when i try to call fileinput.input('test.txt') again. But how can I...
10
by: wo_shi_big_stomach | last post by:
Newbie to python writing a script to recurse a directory tree and delete the first line of a file if it contains a given string. I get the same error on a Mac running OS X 10.4.8 and FreeBSD 6.1. ...
0
by: Phoe6 | last post by:
Hi All, I am able to use urlib2 through proxy. I give proxy credentials and use # Set the Proxy Address proxy_ip = "10.0.1.1:80" proxy_user = 'senthil_or' proxy_password_orig='password'
4
by: Adam Funk | last post by:
I'm using this sort of standard thing: for line in fileinput.input(): do_stuff(line) and wondering whether it reads until it hits an EOF and then passes lines (one at a time) into the...
11
by: jo3c | last post by:
hi everybody im a newbie in python i need to read line 4 from a header file using linecache will crash my computer due to memory loading, because i am working on 2000 files each is 8mb ...
3
by: Robert | last post by:
I would like to count lines in a file using the fileinput module and I am getting an unusual output. ------------------------------------------------------------------------------...
1
by: Robocop | last post by:
I'm running some stupid little script that's supposed to alert me if some fuse link exists. All i do is read in /proc/mounts and look to match the fuse mount command in question, i'm doing this: ...
0
by: John Machin | last post by:
On Nov 18, 9:26 am, Robocop <btha...@physics.ucsd.eduwrote: The "extra" newline is inserted by the print statement. To see unambiguously what you've got, do print repr(line) Yes. It's part...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.