Hi i have been trying to get a GUI in BlueJ working properly but i hav come across a prolem, i hav 2 buttons which i want to use but when i click them the actionListener wont run my methods.
In the action preformed bit i tried to make it so when you pressed the button it would make the NewPatient method work but it came up with the error '.class' was expected', also when i try to use it to call the method getPatient the same error occurs. if anyone could help me with this it would be helpful
Thanks
Chris
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Service desk is a program which can hold multiple service
* requests which can be looked at by members of staff so
* the staff can try and solve them
*
* @author (Chris Holmes)
*/
public class PatientInformationSystem
implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
//System.out.println("item:"+event.getActionCommand());
}
private JFrame frame;
// Storage for the arbitrary number of mail items
//to be stored on the help desk system
private List<Patient> Patients;
//create a new integer called nextuniquenumber
private int nextuniquenumber;
/**
* construct a service desk
*/
public PatientInformationSystem()
{
makeFrame();
//create a new array list
Patients=new ArrayList<Patient>();
nextuniquenumber=1;
}
/**
* This method adds a new request to the system
*/
public void newPatient (int Uniquenumber, String PatientName, String PatientGender,String PatientAddress,String HealthProblem,String CurrentState,String DateAdmitted)
{
Patients.add(new Patient(nextuniquenumber, PatientName, PatientGender, PatientAddress, HealthProblem, CurrentState, DateAdmitted));
//change the uniguenumber value up one
nextuniquenumber++;
}
private void makeFrame()
{
frame= new JFrame("Frame");
Container contentPane=frame.getContentPane();
JLabel label=new JLabel("Patient Information System");
contentPane.add(label);
JButton button=new JButton("Button1");
contentPane.add(button);
JButton quitItem=new JButton("Button2");
quitItem.addActionListener(this);
contentPane.add(quitItem);
frame.pack();
frame.setVisible(true);
}
/**
* This method shows all the Requests on the system
*/
public void showPatients()
{
for(Patient patient : Patients) {
System.out.println(patient);
}
}
public Patient getPatient(int uniquenumber)
{
if ((uniquenumber >=1) && (uniquenumber < nextuniquenumber)){
Patient selectedpatient=Patients.get(uniquenumber-1);
return selectedpatient;
}
else
{
System.out.println("Patient number: " + uniquenumber +
" does not exist.");
return null;
}
}
}
/**
* Each individual Request
*
* Chris Holmes
*/
public class Patient
{
// Variables for each request
public final int PatientID;
public String PatientName;
public String PatientGender;
public String PatientAddress;
public String HealthProblem;
public String CurrentState;
public String DateAdmitted;
/**
*
*/
public Patient(int PatientID, String PatientName, String PatientGender,String PatientAddress,String HealthProblem,String CurrentState,String DateAdmitted)
{
this.PatientID=PatientID;
this.PatientName=PatientName;
this.PatientGender=PatientGender;
this.PatientAddress=PatientAddress;
this.HealthProblem=HealthProblem;
this.CurrentState=CurrentState;
this.DateAdmitted=DateAdmitted;
}
/**
*
*/
public String toSting()
{
String details = PatientID + ": " + PatientName + ":" + PatientGender + ":" + PatientAddress + ":" + HealthProblem + ":" + CurrentState +":" + DateAdmitted;
return details;
}
public int getPatientID()
{
return PatientID;
}
public String getPatientName()
{
return PatientName;
}
public String getPatientGender()
{
return PatientGender;
}
public String getPatientAddresse()
{
return PatientAddress;
}
public String getHealthProblem()
{
return HealthProblem;
}
public String getCurrentState()
{
return CurrentState;
}
public String getDateAdmitted()
{
return DateAdmitted;
}
}