Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 29th, 2004, 6:27 AM   #1
|2yan
Newbie
 
Join Date: Nov 2004
Posts: 2
Rep Power: 0 |2yan is on a distinguished road
Send a message via ICQ to |2yan Send a message via MSN to |2yan
Hi guys. I'm new to this forum. I needed to create a project for my class and it should be either an applet or an application that has fields where a user can enter details and store them in a file. I have created this program, but I'm encountering a few problems. Can you guys please help, I need to submit this tomorrow. Here it is:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;

public class PatientDetails extends JFrame implements ActionListener
{
	JFrame frame;
	JPanel panel;
	JLabel patientFirstName;
	JLabel patientMiddleName;
	JLabel patientLastName;
	JLabel patientPhoneNumber;
	JLabel patientPostalAddress;
	JTextField textPatientFirstName;
	JTextField textPatientMiddleName;
	JTextField textPatientLastName;
	JTextField textPatientPhoneNumber;
	JTextField textPatientPostalAddress;
	JComboBox patientChoice;
	JList paymentOption;
	JButton button;

	public static void main (String args[])
	{
 frame = new JFrame ("PatientDetails");
 panel = new JPanel ();
 frame.getContentPane().add(panel);
 panel.setLayout (new FlowLayout ());
 
 patientFirstName = new JLabel ("First Name: ");
 textPatientFirstName = new JTextField (15);
 
 patientMiddleName = new JLabel ("Middle Name: ");
 textPatientMiddleName = new JTextField (15);
 
 patientLastName = new JLabel ("Last Name: ");
 textPatientLastName = new JTextField (15);
 
 patientPhoneNumber = new JLabel ("Phone Number: ");
 textPatientPhoneNumber = new JTextField (15);
 
 patientPostalAddress = new JLabel ("Address: ");
 textPatientPostalAddress = new JTextField (50);
 
 String listOfPaymentOptions [] = {"Credit Card", "Cash", "Check"};
 paymentOption = new JList (listOfPaymentOptions);
 
 String memberChoice [] = {"New Patient", "Regular Patient", "Guest Patient"};
 patientChoice = new JComboBox (memberchoice);
 
 button = new JButton ("Submit");
 
 panel.add(patientFirstName);
 panel.add(textPatientFirstName);
 panel.add(patientMiddleName);
 panel.add(textPatientMiddleName);
 panel.add(patientLastName);
 panel.add(textPatientLastName);
 panel.add(patientPhoneNumber);
 panel.add(textPatientPhoneNumber);
 panel.add(patientPostalAddress);
 panel.add(textPatientPostalAddress);
 panel.add(paymentOption);
 panel.add(patientChoice);
 panel.add(button);
	}
	public class PatientDetails (ActionEvent addingInfo)
	{
 Object abc = addingInfo.getSource ();
 if (abc == button)
 {
 	String entry = textPatientFirstName.getText () + ":" + textPatientMiddleName.getText () + ":" + textLastName.getText () + ":" + new String
 	(textPatientPhoneNumber.getText()) + ":" + new String (textPatientPostalAddress.getText());
 	try
 	{
  RandomAccessFile patientFile = new RandomAccessFile ("C:\\Documents and Settings\\Ryan\\My Documents\\File.txt", "rw");
  patientFile.seek(patientFile.length());
  patientFile.writeBytes (entry);
 	}
 	catch (IOException error)
 	{
  showStatus ("Cannot write to file" +error);
 	}
 }
	}
}

Any suggestions, can you guys compile it and find out what's wrong. thanks for reading this. By the way, I'm just learning java so if I'm messing up, please tell me where and why.

ryan
|2yan is offline   Reply With Quote
Old Nov 29th, 2004, 10:41 PM   #2
|2yan
Newbie
 
Join Date: Nov 2004
Posts: 2
Rep Power: 0 |2yan is on a distinguished road
Send a message via ICQ to |2yan Send a message via MSN to |2yan
Guess no one could help me. Anyway, I'll have to turn it in this way. Admin, you can close this topic.
|2yan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC