0

Hi thanks that swing tutorial helped, just a quick question im trying to get my search button working atm it looks like this

[CODE]
public JTextField idNumber= new JTextField();

if(event.getActionCommand().equals(SEARCH1))
{
uniquenumber= idNumber.getText();
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;
}
} [/CODE]

When i try to run it, it says incompatible types found..... found string expected int, is this because i am using the getText() or because it is searching in a textfield?, if soo what should i be using instead? thanks chris

0

Sorry, that was a stupid question, but i hav got the button mostly working how i want it to, the problem is now when i press the button it adds a new patient but i can't choose what details the patient will have, how can i change it so that a dialogue box appears where i can enter each indavidual patients details?
[CODE]
if(event.getActionCommand().equals(CHAT))
{
Patients.add(new Patient(nextuniquenumber, PatientName, PatientGender, PatientAddress, HealthProblem, CurrentState, DateAdmitted));

            nextuniquenumber++;
            System.out.println("You Added A New Patient");

        //System.out.println("You pressed the Chat button.");
    }

[/CODE]

This is what i have so far, thanks chris

0

No i tried it without the public void so it was like

[CODE] public void actionPerformed(ActionEvent event)
{
if(event.getActionCommand().equals(CHAT))
{
newPatient (String PatientName, String PatientGender,String PatientAddress,String HealthProblem,String CurrentState,String DateAdmitted);
//System.out.println("You pressed the Chat button.");
}[/CODE]
or
[CODE] public void actionPerformed(ActionEvent event)
{
if(event.getActionCommand().equals(CHAT))
{
getPatient(int uniquenumber);
//System.out.println("You pressed the Chat button.");
}
[/CODE]

i think it may be because i am using the patient class in these methods but im not sure :confused:

Chris

0

Hey Neil, thanks for your help, just a quick one, im still trying to make the buttons work so that the run the methods "public void newPatient" and "public Patient getPatient" i keep getting errors such as ")" expected, i have tried several ways to fix this but non work, any chance you know what im doing wrong? cheers Chris

0

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

[code]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, ...