Hey there guys, I am having a problem with with my ReadFile constructor. First of all the class that I am placing the constructor in is in a different package. I have imported the package to the class that I am placing the constructor But I still get an error (at the red). Please take a look at it for me guys and gals.

package machine;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileReader;


import javax.swing.*;

public class AtmInterface 
{
	
	public static final String EMPTY_STRING = "";
	String numbers;
	String combine = "";
	private JFrame frame;
	private JTextField pin ;
	private JTextArea display;
	private JPanel panel;
	private JLabel label;
	private JPanel subPanel, subPanel2, subPanel3, subPanel4;
	private JButton deposit, withdraw, exit, transaction, balance, enter;
	private JButton button1, button2, button3, button4, button5, button6, button7, button8, button9, button0, button_, buttonEnter;
	

	public AtmInterface()
	{
		
		frame = new JFrame( "ATM Program" );
		panel = new JPanel( new BorderLayout ());
		label = new JLabel ( "Please Enter PIN" );
		subPanel = new JPanel();
		subPanel2 = new JPanel();
		subPanel3 = new JPanel();
		subPanel4 = new JPanel ();
		pin = new JTextField(10);
		
		
		
		display = new JTextArea( 15, 30 );
		balance = new JButton( "Display Account Balance" );
		deposit = new JButton( "Make a Deposit" );
		withdraw = new JButton( "Make a Withdraw" );
		transaction = new JButton ( "New Transaction");
		exit = new JButton ( "Exit" );
		enter = new JButton ( "Enter" );
		
		/*for ( int button = 1; button <= 9; button++ )
		{
			subPanel2.add( new JButton ( "" + button ));
		}*/
		button1 = new JButton("1");
		button2 = new JButton("2");
		button3 = new JButton("3");
		button4 = new JButton("4");
		button5 = new JButton("5");
		button6 = new JButton("6");
		button7 = new JButton("7");
		button8 = new JButton("8");
		button9 = new JButton("9");
		button0 = new JButton("0");
		button_ = new JButton(".");
		buttonEnter = new JButton("Enter");
	
		
		subPanel.setLayout(new GridLayout (5, 0));
		subPanel.setBorder( BorderFactory.createTitledBorder("Task Buttons"));
		subPanel.add(deposit);
		subPanel.add(withdraw);
		subPanel.add(balance);
		subPanel.add(transaction);
		subPanel.add(exit);
		
		
		subPanel2.setLayout(new GridLayout(4,3));
		subPanel2.setBorder( BorderFactory.createTitledBorder("Keypad"));
		subPanel2.add(button1);
		subPanel2.add(button2);
		subPanel2.add(button3);
		subPanel2.add(button4);
		subPanel2.add(button5);
		subPanel2.add(button6);
		subPanel2.add(button7);
		subPanel2.add(button8);
		subPanel2.add(button9);
		subPanel2.add(button0);
		subPanel2.add(button_);
		subPanel2.add(buttonEnter);
		
		subPanel3.setBorder( BorderFactory.createTitledBorder( "Display"));
		display.setBorder( BorderFactory.createLineBorder( Color.RED, 5));
		subPanel3.add( display );
		
		subPanel4.setBorder( BorderFactory.createTitledBorder("Login"));
		subPanel4.setBackground( Color.BLACK );
		label.setForeground( Color.white );
		subPanel4.add( label );
		subPanel4.add(pin);
		subPanel4.add( enter );
		
		
		panel.setBackground( Color.BLACK );
		panel.add(subPanel, BorderLayout.WEST); 
		panel.add(subPanel2, BorderLayout.SOUTH);
		panel.add(subPanel3, BorderLayout.CENTER);
		panel.add(subPanel4, BorderLayout.EAST);

		frame.add( panel );
		frame.setLocation( 250, 300 );
		frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);	
		frame.setSize( 850, 450 );
		frame.setVisible(true);
		
		deposit.addActionListener( new EnterHandler ());
		deposit.addActionListener( new ButtonHandler ());
		withdraw.addActionListener(new WithdrawListener ());
		balance.addActionListener(new ButtonHandler());
		button1.addActionListener(new ButtonHandler());
		button2.addActionListener(new ButtonHandler());
		button3.addActionListener(new ButtonHandler());
		button4.addActionListener(new ButtonHandler());
		button5.addActionListener(new ButtonHandler());
		button6.addActionListener(new ButtonHandler());
		button7.addActionListener(new ButtonHandler());
		button8.addActionListener(new ButtonHandler());
		button9.addActionListener(new ButtonHandler());
		button0.addActionListener(new ButtonHandler());
		button_.addActionListener(new ButtonHandler());
		buttonEnter.addActionListener(new ButtonHandler());
		
	}
	
	private class ButtonHandler implements ActionListener
	{
               /* Checking check = new Checking();
                double value = 0.00;
        
                public void set()
                {
                    check.setBalance(check.getBalance() + value); 
                }*/
            
		public void actionPerformed(ActionEvent event )
		{
			
			JButton clickedButton = (JButton) event.getSource();
			Transactions query = new Transactions ();
			
				
				if( clickedButton == button1 )
				{
					numbers = String.valueOf(1);
					display.append(event.getActionCommand());
				   
				}
				
				else
					if ( clickedButton == button2 )
					   {
						 numbers = String.valueOf(2);
						 display.append(event.getActionCommand());
					   }
					else
						if ( clickedButton == button3 )
						   {
							 numbers = String.valueOf(3);
							 display.append(event.getActionCommand());
						   }
						else
							if ( clickedButton == button4 )
							   {
								 numbers = String.valueOf(2);
								 display.append(event.getActionCommand());
							   }
							else
								if ( clickedButton == button5 )
								   {
									 numbers = String.valueOf(2);
									 display.append(event.getActionCommand());
								   }
								else
									if ( clickedButton == button6 )
									   {
										 numbers = String.valueOf(2);
										 display.append(event.getActionCommand());
									   }
									else
										if ( clickedButton == button7 )
										   {
											 numbers = String.valueOf(2);
											 display.append(event.getActionCommand());
										   }
										else
											if ( clickedButton == button8 )
											   {
												 numbers = String.valueOf(2);
												 display.append(event.getActionCommand());
											   }
											else
												if ( clickedButton == button9 )
												   {
													 numbers = String.valueOf(2);
													 display.append(event.getActionCommand());
												   }
				 
				
				combine = display.getText();
				JOptionPane.showMessageDialog(null, String.format ("Text has : %s", combine));

			
			}
		}
	
	
	private class WithdrawListener implements ActionListener
	{
		
		public void actionPerformed ( ActionEvent event )
		{
			
			JButton clickedButton = (JButton) event.getSource();
			Transactions query = new Transactions ();
			
			if ( clickedButton == withdraw )
			{
				display.append( "What is your withdrawal amount?: " );
				ButtonHandler keypad = new ButtonHandler ();
				keypad.actionPerformed(event);
				query.setWithdraw( Double.parseDouble(combine));
				query.withdraw();
				
				//numbers = String.valueOf(display.getText());
				//numbers = display.getText();
			}
			//display.setText( EMPTY_STRING );
			//JOptionPane.showMessageDialog(null, String.format ("Text has : %s", combine));
		}
	}
	
	private class EnterHandler implements ActionListener
	{
		
		public void actionPerformed ( ActionEvent event )
		{
			
			FileReader read = new FileReader();
			JButton clickedButton = (JButton) event.getSource();
			Transactions query = new Transactions ();
			
			if ( clickedButton == enter )
			{
				
				
			
				//numbers = String.valueOf(display.getText());
				//numbers = display.getText();
			}
		}
	}
}

Take a look at the java page on FileReader() which lists 3 possible constructors.

http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileReader.html

I do not see a constructor that can be used without passing a parameter to the constructor. i.e i don't see new FileReader();

maybe this constructor they list there would work:

FileReader(String fileName)
Creates a new FileReader, given the name of the file to read from.

mike

Then I would say the OP is confused by the lack of a no argument constructor. The no argument constructor is only automagically present if the class does not provide any other constructors. I.e., since FileReader has other constructors, the compiler would not provide a no argument constructor automagically, and the only reason one would be there is if someone had explicitly written one.

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.