Results 1 to 12 of 12

Thread: Need Help>.<

  1. #1
    EdwardVincent is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Default Need Help>.<

    I'm doing an assigement on Java and meet with some problem,
    I had use JTextField for accept my data and used JOptionPane.showConfirmDialog to show the keyin boxes, but when every time i click the OK button ,the program stop....it can not continue to the next public void....


    i had try change the JOptionPane.showConfirmDialog to JOptionPane.showMessageDialog , and using JButton but i dun know how to make the button work~.~

    ps: i need it jump to "Verify_patient_blood_pressure()"

    public void Accept_patient_blood_pressure()
    {
    JFrame jtfMainFrame = new JFrame("Blood Pressure");
    JTextField jtfInput = new JTextField(null,10);
    JTextField jtfInput2 = new JTextField(null,10);
    JButton ok = new JButton("OK");
    JPanel jplPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));



    jplPanel.add(new JLabel("Blood Pressure : "));
    jplPanel.add(jtfInput);
    jplPanel.add(new JLabel("/"));
    jplPanel.add(jtfInput2);
    JPanel content = new JPanel( new FlowLayout(FlowLayout.LEFT) );
    content.add( jplPanel , BorderLayout.SOUTH );

    JOptionPane.showMessageDialog(null,content,"Blood Pressure",JOptionPane.INFORMATION_MESSAGE);
    }
    Last edited by EdwardVincent; 08-03-2008 at 01:31 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default

    You'll have to show more of your program.
    What does the small section of code you show do or not do?

  3. #3
    EdwardVincent is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Default

    The program i haven't done all the part yet...this is the part i had done.....

    //import package
    import java.awt.FlowLayout.*;
    import java.awt.event.ActionListener.*;
    import java.awt.event.ActionEvent.*;
    import javax.swing.JFrame.*;
    import javax.swing.JButton.*;
    import javax.swing.Icon.*;
    import javax.swing.ImageIcon.*;
    import javax.swing.JOptionPane.*;

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.datatransfer.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.table.*;


    //A class name pdp was created for store the detail
    public class pdp
    {
    //Declaring all the data that will need to use.
    String patient_name ,patient_gender, patient_snum ,result_num ,patient_sage ,result_age ,patient_sheight ,patient_sweight ,result_bmi, patient_discount,patient_bmic, patient_sactivity_rates, result_ER, jtfMainFrame, jtfInput,jtfInput2,jplPanel,BP_result,answer,patie nt_BSL ;
    int patient_number , patient_age, patient_age_result ,void_gender, void_bmi, void_patient_activity_rates, patient_activity_rates, patient_sbp, patient_dbp,BSL ;
    float patient_height , patient_weight;
    double patient_bmi, patient_mheight, patient_bmr, patient_calorie;
    char f,F,Female,female,M,m,Male,male;

    public void pdp()
    {
    patient_name = " ";
    patient_gender = " ";
    patient_number = 0;
    result_num = " ";
    patient_age = 0;


    }

    //accepting the patients name.
    public void Accept_Patient_name()
    {
    patient_name = JOptionPane.showInputDialog(null,"Enter Patients Name","Patients Name");

    }

    public void Accept_Patient_gender()
    {
    patient_gender = JOptionPane.showInputDialog(null,"Enter Patients Gender, Female or Male","Patient Gender");
    if(patient_gender.equals("f"))
    {
    void_gender=1;

    }
    else if(patient_gender.equals("F"))
    {
    void_gender=2;
    }
    else if(patient_gender.equals("female"))
    {
    void_gender=3;
    }
    else if(patient_gender.equals("Female"))
    {
    void_gender=4;
    }
    else if(patient_gender.equals("m"))
    {
    void_gender=5;
    }
    else if(patient_gender.equals("M"))
    {
    void_gender=6;
    }
    else if(patient_gender.equals("Male"))
    {
    void_gender=7;
    }
    else if(patient_gender.equals("male"))
    {
    void_gender=8;
    }
    else
    {
    void_gender=9;
    }
    switch(void_gender)
    {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    JOptionPane.showMessageDialog(null,"Your Gender Had Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    break;

    default:
    JOptionPane.showMessageDialog(null,"Undefined Gender, Please Key In Your Gender Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_Patient_gender();
    break;
    }


    }

    public void Accept_Patient_number()
    {

    patient_snum = JOptionPane.showInputDialog(null,"Enter The Patients Number","Patients Number");
    patient_number = Integer.parseInt(patient_snum);

    if(patient_number >= 1)
    {
    JOptionPane.showMessageDialog(null,"Your Number Had Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    }
    else
    {
    JOptionPane.showMessageDialog(null,"Undefined Number, Please Key In Your Number Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_Patient_number();
    }

    }

    public void Accept_Patient_age()
    {

    patient_sage = JOptionPane.showInputDialog(null,"Enter Patients Age","Patients Age");
    patient_age = Integer.parseInt(patient_sage);
    if ((patient_age >= 0) && (patient_age <= 100))
    {
    JOptionPane.showMessageDialog(null,"Your Age Had Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    if((patient_age >= 40)&&(patient_age <= 59))
    {
    patient_age_result = 1;
    }
    else if (patient_age >60)
    {
    patient_age_result = 2;
    }
    else if (patient_age < 39)
    {
    patient_age_result = 3;
    }

    }
    else
    {
    JOptionPane.showMessageDialog(null,"Undefined Age, Please Key In Your Age Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_Patient_age();
    }

    }

    public void Verify_Age()
    {
    if((patient_number >= 1)&&(patient_number <= 100))
    {
    switch(patient_age_result)
    {
    case (1):
    patient_discount = "25%";
    break;

    case (2):
    patient_discount = "35%";
    break;

    case (3):
    patient_discount = "10%";
    break;
    }
    }
    else
    {
    patient_discount = "no";
    }
    }

    public void Accept_patient_height()
    {
    patient_sheight= JOptionPane.showInputDialog(null,"Enter Your Height In cm","cm");
    patient_height= Float.parseFloat(patient_sheight);
    if((patient_height >= 20)&&(patient_height <= 220))
    {
    JOptionPane.showMessageDialog(null,"Your Height Had Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    }
    else
    {
    JOptionPane.showMessageDialog(null,"Undefined Height, Please Key In Your Height Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_patient_height();
    }

    }

    public void Accept_patient_weight()
    {

    patient_sweight= JOptionPane.showInputDialog(null,"Enter Your Weight In kg","kg");
    patient_weight= Float.parseFloat(patient_sweight);
    if((patient_weight >= 2)&&(patient_weight <= 350))
    {
    JOptionPane.showMessageDialog(null,"Your Weight Had Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    }
    else
    {
    JOptionPane.showMessageDialog(null,"Undefined Weight, Please Key In Your Weight Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_patient_weight();
    }

    }

    public void Count_patient_bmi()
    {
    patient_mheight=patient_height/100;
    patient_bmi = patient_weight/(patient_mheight*patient_mheight);
    if((patient_bmi>=18)&&(patient_bmi<=25))
    {
    patient_bmic = "slim";
    void_bmi = 1;
    }
    else if((patient_bmi>=26)&&(patient_bmi<=39))
    {
    patient_bmic = "fat";
    void_bmi = 2;
    }
    else if(patient_bmi>40)
    {
    patient_bmic = "Obese";
    void_bmi = 3;
    }
    else
    {
    patient_bmic="thin";
    void_bmi = 4;
    }
    }

    public void Accept_patient_activity_rates()
    {
    patient_sactivity_rates = JOptionPane.showInputDialog(null,"How Much Exercise Done In A Month? \n(1)1 or 2 time a month \n(2)every week once \n(3)2 to 4 times a week \n(4)5 time a week \n(5)almost everyday","1?2?3?4?5?");
    patient_activity_rates = Integer.parseInt(patient_sactivity_rates);
    if ((patient_activity_rates >= 1)&&(patient_activity_rates <= 5))
    {
    JOptionPane.showMessageDialog(null,"Your Details Has Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    switch(patient_activity_rates)
    {
    case 1 : result_ER = "1 or 2 time a month";
    case 2 : result_ER = "every week once";
    case 3 : result_ER = "2 to 4 times a week";
    case 4 : result_ER = "5 time a week";
    case 5 : result_ER = "almost everyday";
    }
    }
    else
    {
    JOptionPane.showMessageDialog(null,"Undefined Numbers \nPlease Key-In Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_patient_activity_rates();
    }
    }

    public void Verify_patient_bmr()
    {
    if((void_gender >= 5)&&(void_gender <= 8))
    {
    patient_bmr=66+(13.7*patient_weight)+(5*patient_he ight) - (6.8*patient_age);
    }
    else if((void_gender >= 1)&&(void_gender <= 4))
    {
    patient_bmr=655 + ( 9.6*patient_weight ) + ( 1.8*patient_height ) - ( 4.7*patient_age );
    }
    }

    public void Verify_patient_Calorie()
    {
    if(patient_activity_rates == 1)
    {
    patient_calorie = patient_bmr *1.2;
    }
    else if(patient_activity_rates == 2)
    {
    patient_calorie = patient_bmr *1.375;
    }
    else if(patient_activity_rates == 3)
    {
    patient_calorie = patient_bmr *1.55;
    }
    else if(patient_activity_rates == 4)
    {
    patient_calorie = patient_bmr *1.725;
    }
    else if(patient_activity_rates == 5)
    {
    patient_calorie = patient_bmr *1.9;
    }
    }

    public void Accept_patient_blood_pressure()
    {
    JFrame jtfMainFrame = new JFrame("Blood Pressure");
    JTextField jtfInput = new JTextField(null,10);
    JTextField jtfInput2 = new JTextField(null,10);
    JButton ok = new JButton("OK");
    JPanel jplPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));



    jplPanel.add(new JLabel("Blood Pressure : "));
    jplPanel.add(jtfInput);
    jplPanel.add(new JLabel("/"));
    jplPanel.add(jtfInput2);
    JPanel content = new JPanel( new FlowLayout(FlowLayout.LEFT) );
    content.add( jplPanel , BorderLayout.SOUTH );

    JOptionPane.showMessageDialog(null,content,"Blood Pressure",JOptionPane.INFORMATION_MESSAGE);
    }

    public void Verify_patient_blood_pressure()
    {
    patient_sbp = Integer.parseInt(jtfInput);
    patient_dbp = Integer.parseInt(jtfInput2);

    if((patient_sbp>=90)&&(patient_sbp<100)&&(patient_ dbp>=60)&&(patient_dbp<75))
    {
    BP_result="You have low blood pressure."+"\n"+"\tHYPOTENSION"+"\n"+"\tConsult doctor to get HELP";
    }
    else if((patient_sbp>=100)&&(patient_sbp<120)&&(patient _dbp>=75)&&(patient_dbp<80))
    {
    BP_result="You have normal blood pressure."+"\n"+"\tGOOD FOR YOU and KEEP IT WELL";
    }
    else if((patient_sbp>=120)&&(patient_sbp<140)&&(patient _dbp>=80)&&(patient_dbp<90))
    {
    BP_result="You are at high risk of high blood pressure."+"\n"+"\tYou need to take action NOW!"+"\n"+"\tMake changes in what you eat and drink, be physically active, and lose extra weight."+"\n\tPREHYPERTENSION"+"\n"+"\tSee your Doctor NOW!!";
    }
    else if((patient_sbp>=140)&&(patient_sbp<160)&&(patient _dbp>=90)&&(patient_dbp<100))
    {
    BP_result="You have high blood pressure."+"\n"+"\tSTAGE 1 HYPERTENSION"+"\n"+"\tCONSULT DOCTOR TO GET HELP!!";
    }
    else if((patient_sbp>=160)&&(patient_dbp>=100))
    {
    BP_result="You have high blood pressure."+"\n"+"\tSTAGE 2 HYPERTENSION"+"\n"+"\tCONSULT DOCTOR TO GET HELP!!";
    }
    else if ((patient_sbp > 160)||(patient_sbp < 90)||(patient_dbp > 100)||(patient_dbp < 60))
    {
    JOptionPane.showMessageDialog(null, "incorrect blood pressure, please key in again");
    pdp c = new pdp();
    c.Accept_patient_blood_pressure();

    }
    }

    public void Accept_patient_BSL()
    {
    patient_BSL = JOptionPane.showInputDialog(null,"Enter Your Blood Sugar in mg/dL form","Example : 120");

    BSL = Integer.parseInt(patient_BSL);
    if ((BSL >= 80)&&(BSL <= 250))
    {
    JOptionPane.showMessageDialog(null,"Your Details Has Been Accepted","Message",JOptionPane.INFORMATION_MESSAG E);
    }
    else
    {
    JOptionPane.showMessageDialog(null,"Incorrect Varible!! \n Please Key In Again","Message",JOptionPane.INFORMATION_MESSAGE);
    pdp c = new pdp();
    c.Accept_patient_BSL();
    }

    }


    public void Display_Detail()
    {
    JTextArea detail = new JTextArea(null, 10, 10);
    detail.append("Patient Name : \t " + patient_name + "\n");
    detail.append("Patient Number : \t" + patient_number + "\n");
    detail.append("Patient Gender : \t" + patient_gender + "\n");
    detail.append("Patient Age : \t" + patient_age + "\n");
    detail.append("Patient Get " + patient_discount + "discount \n");
    detail.append("Patient Height : \t"+ patient_height+"cm \n");
    detail.append("Patient Weight : \t"+ patient_weight+"kg \n");
    detail.append("Patient BMI : \t" + patient_bmi + "\n");
    detail.append("Patient Are " + patient_bmic + "\n");
    detail.append("Patient Exercise Rate : \t" + result_ER + "\n");
    detail.append("Patient Basal Metabolic Rate :\t " + patient_bmr + "\n");
    detail.append("this patient should has \t"+patient_calorie+"\t calories intake");
    detail.append("Patient Blood Pressure : \t" + patient_sbp +"/" + patient_dbp + "\n" );
    detail.append(BP_result + "\n");



    JOptionPane.showMessageDialog(null,detail,"Result" ,JOptionPane.INFORMATION_MESSAGE);
    }

    public void AskForContinue( )
    {
    answer = JOptionPane.showInputDialog(null,"Do you want to continue....\nEnter Y or y for YES & \nEnter N or n for NO", "User Request", JOptionPane.QUESTION_MESSAGE);

    if(answer.equals("Y")||answer.equals("y"))
    {


    pdp c = new pdp();
    int loop=0;
    loop++;

    c.Accept_Patient_name();
    c.Accept_Patient_gender();
    c.Accept_Patient_number();
    c.Accept_Patient_age();
    c.Verify_Age();
    c.Accept_patient_height();
    c.Accept_patient_weight();
    c.Count_patient_bmi();
    c.Accept_patient_activity_rates();
    c.Verify_patient_bmr();
    c.Verify_patient_Calorie();
    c.Accept_patient_blood_pressure();
    c.Verify_patient_blood_pressure();
    c.Accept_patient_BSL();

    c.Display_Detail();
    c.AskForContinue( );
    }


    }
    public static void main ( String [ ] args )
    {
    pdp c = new pdp();
    c.Accept_Patient_name();
    c.Accept_Patient_gender();
    c.Accept_Patient_number();
    c.Accept_Patient_age();
    c.Verify_Age();
    c.Accept_patient_height();
    c.Accept_patient_weight();
    c.Count_patient_bmi();
    c.Accept_patient_activity_rates();
    c.Verify_patient_bmr();
    c.Verify_patient_Calorie();
    c.Accept_patient_blood_pressure();
    c.Verify_patient_blood_pressure();
    c.Accept_patient_BSL();

    c.Display_Detail();
    c.AskForContinue( );
    }
    }

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default

    That's too much code to look at without specific directions from you as to what the problem is. Especially since
    i haven't done all the part yet
    Can you describe the problem and point out where in your code you are having a problem?
    What does
    how to make the button work
    mean?
    ActionListeners are used to handle button presses. In the method, you do what you want done for that button press. If the work to be done is too much, start a thread to do it.
    To figure out how to use a feature or method, write a SMALL test program first and get that to work before trying to put it into the main program. Then when you have problems, you can post the SMALL program with questions on how to get it to work.

  5. #5
    EdwardVincent is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Default

    i have try use ActionListeners for many time but it still can not jump to the public that i wanted....
    {sometime there have no error, but still can not countinue}

    i'm jz started in java, so i not sure where to put ActionListeners....

    i want it loop to "verify"(orange) when i press the "ok" button(red)
    public void Accept_patient_blood_pressure()
    {
    JFrame jtfMainFrame = new JFrame("Blood Pressure");
    JTextField jtfInput = new JTextField(null,10);
    JTextField jtfInput2 = new JTextField(null,10);
    JButton ok = new JButton("OK");
    JPanel jplPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));



    jplPanel.add(new JLabel("Blood Pressure : "));
    jplPanel.add(jtfInput);
    jplPanel.add(new JLabel("/"));
    jplPanel.add(jtfInput2);
    JPanel content = new JPanel( new FlowLayout(FlowLayout.LEFT) );
    content.add( jplPanel , BorderLayout.SOUTH );

    JOptionPane.showMessageDialog(null,content,"Blood Pressure",JOptionPane.INFORMATION_MESSAGE);
    }

    public void Verify_patient_blood_pressure()
    {
    patient_sbp = Integer.parseInt(jtfInput);
    patient_dbp = Integer.parseInt(jtfInput2);

    if((patient_sbp>=90)&&(patient_sbp<100)&&(patient_ dbp>=60)&&(patient_dbp<75))
    {
    BP_result="You have low blood pressure."+"\n"+"\tHYPOTENSION"+"\n"+"\tConsult doctor to get HELP";
    }
    else if((patient_sbp>=100)&&(patient_sbp<120)&&(patient _dbp>=75)&&(patient_dbp<80))
    {
    BP_result="You have normal blood pressure."+"\n"+"\tGOOD FOR YOU and KEEP IT WELL";
    }
    else if((patient_sbp>=120)&&(patient_sbp<140)&&(patient _dbp>=80)&&(patient_dbp<90))
    {
    BP_result="You are at high risk of high blood pressure."+"\n"+"\tYou need to take action NOW!"+"\n"+"\tMake changes in what you eat and drink, be physically active, and lose extra weight."+"\n\tPREHYPERTENSION"+"\n"+"\tSee your Doctor NOW!!";
    }
    else if((patient_sbp>=140)&&(patient_sbp<160)&&(patient _dbp>=90)&&(patient_dbp<100))
    {
    BP_result="You have high blood pressure."+"\n"+"\tSTAGE 1 HYPERTENSION"+"\n"+"\tCONSULT DOCTOR TO GET HELP!!";
    }
    else if((patient_sbp>=160)&&(patient_dbp>=100))
    {
    BP_result="You have high blood pressure."+"\n"+"\tSTAGE 2 HYPERTENSION"+"\n"+"\tCONSULT DOCTOR TO GET HELP!!";
    }
    else if ((patient_sbp > 160)||(patient_sbp < 90)||(patient_dbp > 100)||(patient_dbp < 60))
    {
    JOptionPane.showMessageDialog(null, "incorrect blood pressure, please key in again");
    pdp c = new pdp();
    c.Accept_patient_blood_pressure();

    }
    }

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default

    To figure out how to use a feature or method, write a SMALL test program first and get that to work before trying to put it into the main program. Then when you have problems, you can post the SMALL program with questions on how to get it to work.
    Write a simple gui with a button. Have the actionlistener print something on the screen when the button is pressed.
    Use Search for ActionListener for examples on how to code action listeners.

  7. #7
    EdwardVincent is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Default

    i try to change it to showConfirmDialog, but still can not loop to next public void
    public void Accept_patient_blood_pressure()
    {
    JTextField jtfInput = new JTextField(null,10);
    JTextField jtfInput2 = new JTextField(null,10);
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(new JLabel("Blood Pressure : "));
    getContentPane().add(jtfInput);
    getContentPane().add(new JLabel("/"));
    getContentPane().add(jtfInput2);


    int result = JOptionPane.showConfirmDialog(null,getContentPane( ),"Input",JOptionPane.OK_CANCEL_OPTION);
    if (result == JOptionPane.OK_OPTION)
    {
    pdp c = new pdp();
    c.Verify_patient_blood_pressure();
    }

    }

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default

    still can not loop to next public void
    What does the above mean? You use the term loop followed by what looks like the beginning of a method declaration: public void.
    What does the JOptionPane.show... have to do with a listener?
    You posted the code for a method. Does that method work ok?
    I have no idea what you are trying to do.

  9. #9
    EdwardVincent is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Default

    i had solve the problem myself ....
    the proble is that is have to change the JtestField data to Int 1st
    JTextField jtfInput = new JTextField((new Integer(patient_sbp)).toString(),5);
    Thx anyway ^^

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default

    Glad to hear it. That's the idea, to get you to solve your problem.
    Mark question as solved

  11. #11
    EdwardVincent is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Default

    hehe...now got other problem...
    after i key in the data, it can not save and display....

    For Example :
    i key in 120 in "JTextField" 1
    80 in "JTextField"2
    Then i change the String from "JTextField" 1 & 2 into integer by using
    patient_sbp = Integer.parseInt(jtfInput.getText()) ;
    patient_dbp = Integer.parseInt(jtfInput2.getText()) ;

    Then i use "JTextArea" to show result, but the result is 0/0 not 120/80

    PS : code here
    public void Accept_patient_blood_pressure()
    {
    JTextField jtfInput = new JTextField(10);
    JTextField jtfInput2 = new JTextField(10);
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(new JLabel("Blood Pressure : "));
    getContentPane().add(jtfInput);
    getContentPane().add(new JLabel("/"));
    getContentPane().add(jtfInput2);

    Object[] options = { "OK" };
    JOptionPane.showOptionDialog(null, getContentPane(), "Input", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[0]);

    if (options.equals("OK"))
    {
    patient_sbp = Integer.parseInt(jtfInput.getText()) ;
    patient_dbp = Integer.parseInt(jtfInput2.getText()) ;
    T_BP = patient_sbp - patient_dbp;

    if ((T_BP >=38)&&(T_BP <= 40))
    {
    if((patient_sbp>=90)&&(patient_sbp<100)&&(patient_ dbp>=60)&&(patient_dbp<75))
    {
    BP_result="You have low blood pressure."+"\n"+"\tHYPOTENSION"+"\n"+"\tConsult doctor to get HELP";
    }
    else if((patient_sbp>=100)&&(patient_sbp<120)&&(patient _dbp>=75)&&(patient_dbp<80))
    {
    BP_result="You have normal blood pressure."+"\n"+"\tGOOD FOR YOU and KEEP IT WELL";
    }
    else if((patient_sbp>=120)&&(patient_sbp<140)&&(patient _dbp>=80)&&(patient_dbp<90))
    {
    BP_result="You are at high risk of high blood pressure."+"\n"+"\tYou need to take action NOW!"+"\n"+"\tMake changes in what you eat and drink, be physically active, and lose extra weight."+"\n\tPREHYPERTENSION"+"\n"+"\tSee your Doctor NOW!!";
    }
    else if((patient_sbp>=140)&&(patient_sbp<160)&&(patient _dbp>=90)&&(patient_dbp<100))
    {
    BP_result="You have high blood pressure."+"\n"+"\tSTAGE 1 HYPERTENSION"+"\n"+"\tCONSULT DOCTOR TO GET HELP!!";
    }
    else if((patient_sbp>=160)&&(patient_dbp>=100))
    {
    BP_result="You have high blood pressure."+"\n"+"\tSTAGE 2 HYPERTENSION"+"\n"+"\tCONSULT DOCTOR TO GET HELP!!";
    }
    else if ((patient_sbp > 160)||(patient_sbp < 90)||(patient_dbp > 100)||(patient_dbp < 60))
    {
    JOptionPane.showMessageDialog(null, "incorrect blood pressure, please key in again");
    pdp c = new pdp();
    c.Accept_patient_blood_pressure();

    }
    }
    else
    {
    JOptionPane.showMessageDialog(null, "incorrect blood pressure, please key in again","Message",JOptionPane.WARNING_MESSAGE);
    pdp c = new pdp();
    c.Accept_patient_blood_pressure();
    }
    }
    }

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default

    Object[] options = { "OK" };
    JOptionPane.showOptionDialog(null, getContentPane(), "Input", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[0]);

    if (options.equals("OK"))
    Does the above compile? options is defined as an array, but referenced as a scalar(not an array) It appears to compile, but I don't think it's what you want.

    Get values into variables and use println() to show values to see what is being input
    Last edited by Norm; 08-04-2008 at 01:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •