Ok so I have been working on this for 12 hours straight and I cannot get it to work right to save my life. Attached is the word document of what the project is suppose to do and the file its suppose to read from.

ANY HELP IS GREATLY APPRECIATED IM ABOUT OUT OF REDBULL :)

/*
*
* Filename: FinalProject.java
* Created: 3/1/2010 david ayres
* Purpose: calculates average, maximum, and minimum incomes using do...while and for loops
*/

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.util.Scanner;
import java.lang.String;


public class FinalProject extends JFrame
{
	//static variables to hold frame dimensions in pixels
	private static final int WIDTH = 480;
	private static final int HEIGHT = 550;

	//declare component objects
	private JLabel DateLabel, TNGasLabel, TDSalesLabel, GalRegGasLabel, GalEtLabel;
	private JTextField DateTextField, TNGasTextField, TDSalesTextField, GalRegGasTextField, GalEtTextField;
	private JButton CalcB, ClearB, CloseB;

	//declare event handlers
	private CalcButtonHandler cbHandler;
	private ClearButtonHandler clbHandler;
	private CloseButtonHandler exHandler;


	public FinalProject() //constructor that defines frame
	{
		setTitle( "Gas Feeder System" ); //set the title of the frame
		setSize( WIDTH, HEIGHT ); //set the frame size

		Container pane = getContentPane(); //get content pane (a JFrame method)

		GridLayout aGrid = new GridLayout( 7, 2 ); //create a 5-row, 3-column layout

		pane.setLayout(aGrid); //set the layout for the pane

		//instantiate JLabel objects
		DateLabel = new JLabel( "Date File Created (mm-dd-yy):" );
		TNGasLabel = new JLabel( "Total Number of Gasoline Transactions:" );
		TDSalesLabel = new JLabel( "Total Dollars of ALL Sales:" );
		GalRegGasLabel = new JLabel( "Gallons of Regular Gasoline Sold:" );
		GalEtLabel = new JLabel( "Gallons of 10% Ethanol Gasoline Sold:" );

		//instantiate JTextField objects
		DateTextField = new JTextField( 5 );
		TNGasTextField = new JTextField( 5 );
		TDSalesTextField = new JTextField( 5 );
		GalRegGasTextField = new JTextField( 5 );
		GalEtTextField = new JTextField( 5 );
		TNGasTextField.setEditable(false);
		TDSalesTextField.setEditable(false);
		GalRegGasTextField.setEditable(false);
		GalEtTextField.setEditable(false);


		//instantiate JButtons objects
		CalcB = new JButton( "Calculate");
		cbHandler = new CalcButtonHandler();
		CalcB.addActionListener( cbHandler );
		ClearB = new JButton( "Clear" );
		clbHandler = new ClearButtonHandler();
		ClearB.addActionListener( clbHandler );
		CloseB = new JButton( "Close" );
		exHandler = new CloseButtonHandler();
		CloseB.addActionListener( exHandler );

		//add objects to the pane
		pane.add( DateLabel );
		pane.add( DateTextField );
		pane.add( TNGasLabel );
		pane.add( TNGasTextField );
		pane.add( TDSalesLabel );
		pane.add( TDSalesTextField );
		pane.add( GalRegGasLabel );
		pane.add( GalRegGasTextField );
		pane.add( GalEtLabel );
		pane.add( GalEtTextField );
		pane.add( CalcB );
		pane.add( ClearB );
		pane.add( CloseB );

		centerFrame( WIDTH, HEIGHT ); // METHOD TO CALL CENTER FRAME ON SCREEN

	}//end of constructor

	//inner clases for Button  Handler
	private class CalcButtonHandler implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
				
				try
				{
				//input
				File inFile = new File( "RAWTRANS.TXT" ); //locate data source



						FileReader aFileReader = new FileReader( inFile );//create pipeline
						//create valve
						BufferedReader aBR = new BufferedReader( aFileReader );
						RawData = aBR.readLine();//open valve
						String TotalDollarsAllSales = RawData.substring(12,6);
						String StockCode = RawData.substring(20,6);
						
			//			System.out.println("Reading File");

				}//try
			catch(Exception el)
			{
				System.out.println("error");
			}
			//TotalGasTran = RawData.substring();
			System.out.println("Works");

				//TDSalesTextField.setText( TotalDollarsAllSales );


		}//end actionPerformed
	}//end class Button Handler

	private class ClearButtonHandler implements ActionListener
		{
			public void actionPerformed(ActionEvent e)
			{
				//set text fields to empty strings
				DateTextField.setText( "" );
				TNGasTextField.setText( "" );
				TDSalesTextField.setText( "" );
				GalRegGasTextField.setText( "" );
				GalEtTextField.setText( "" );
			}//end actionPerformed
	}//end class Button Handler

		private class CloseButtonHandler implements ActionListener
			{
				public void actionPerformed(ActionEvent e)
				{
					System.exit(0);
				}//end actionPerformed
		}//end class Button Handler







	public void centerFrame( int frameWidth, int frameHeight )
	{
		//create Toolkit object
		Toolkit aToolkit = Toolkit.getDefaultToolkit();

		//Create a dimension object with user screen information
		Dimension screen = aToolkit.getScreenSize();

		//assign x, y position of upper-left corner of frame
		int xUpperLeftCorner = ( screen.width - frameWidth ) /2;
		int yUpperLeftCorner = ( screen.height - frameHeight ) /2;

		// method to position frame on user's screen
		setBounds(xUpperLeftCorner, yUpperLeftCorner, frameWidth, frameHeight);
	}// end frame


/* *****  COULD BE that your "throws FileNotFoundException, IOException" statement in the method
********  declaration for the main method is the thing causing the trouble.  You would not use it
********  IF you are encasing the the input/output statements within a try-catch-finally.  What does
********  it do?  Using these things in a potentially redundant manner will not gain anything.  Try
********  reorganizing it .........
*/

	public static void main( String[] args) throws FileNotFoundException, IOException
	{

		//**************************************************************
		JFrame aFinalProject = new FinalProject();
		aFinalProject.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		aFinalProject.setVisible( true );
		//**************************************************************





	}//end main

}// end of public class extend FinalProject

Edited 6 Years Ago by Nick Evan: Added code-tags

Attachments
001001513000007070002090000007857p000001025990080203100241SC1001p00000011165412500875101
001001513100008220002090000009131p000001045991080203100541SC1001p00000011225923120215425
001001513200012710002090000014120p000001045992080203102541SC1001p00000010982013290715160
001001513300011170002090000012414p000001045993080203103441SC1001p00000010365413202095100
001001513400009000002090000009996p000001025994080203104741SC1001p00000010669713200265160
001001513500011060002090000012289p000001045995080203105741SC1001p00000010370912008945160
001001513600010290002090000011428p000001045996080203110641SC1001p00000010025012008965160
001001513700014820002090000016472p000001025997080203113841SC1001p00000010030623140195425
001001513800005560002090000006175p000001025998080203121341SC1001p00000010000612008965160
001001513900014490002090000016102p000001025999080203125841SC1001p00000010038112008965160
001001514000017000002090000018891p000001026000080203132741SC1001p00000010102513200265160
001001514100015710002090000017455p000001046001080203133341SC1001p00000011023723150215425
001001514200012500002090000013892p000001046002080203134541SC1001p00000010610913485085160
001001514300018210002090000020235p000001026003080203135741SC1001p00000011165512019355130
001001514400011670002090000012972p000001026004080203140241SC1001p00000010371913002485140
001001514500013500002090000014996p000001046005080203142141SC1001p00000010032013201225159
001001514600015900002090000017672p000001046006080203150041SC1001p00000010018212008255100
001001514700006500002090000007217p000001046007080203151341SC1001p00000011268612037305160
001001514900009890002090000010988p000001026008080203151641SC1001p00000011380613002245170
001001515000011600002090000012886p000001046009080203151941SC1001p00000011168113290575160
001001515100007300002090000008106p000001046010080203155341SC1001p00000010395712008955160
001001515200020000002090000022225p000001026011080203161341SC1001p00000011200323150215425
This article has been dead for over six months. Start a new discussion instead.