Results 1 to 2 of 2

Thread: Help!!!

  1. #1
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default Help!!!

    Help!!
    I am new to Java and having a really hard time understanding it! I have to make a swing based heart rate calculator and I am having all sorts of problems with it. Here is the code.

    public class hrcalc extends Frame implements ActionListener
    {
    double maxHeartRate = 0.0;
    double age = 0;
    JTextField myTextField = new JTextField();



    private static void cFrame()
    {
    public hrcalc ()
    {
    //Create and set up the window.
    JFrame frame = new JFrame("Heart Rate Calculator");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

    JLabel emptyLabel = new JLabel("Please enter your age.");
    emptyLabel.setPreferredSize(new Dimension(300, 200));
    frame.getContentPane().add(emptyLabel, BorderLayout.NORTH);
    frame.getContentPane().add(myTextField, BorderLayout.CENTER);

    //Display the window.
    frame.pack();
    frame.setVisible(true);

    //JTextField myTextField = new JTextField(16);
    }
    }

    public void actionPerformed(ActionEvent e)
    {

    }

    public static void main(String[] args)
    {

    javax.swing.SwingUtilities.invokeLater(new Runnable()
    {
    public void run()
    {
    cFrame();
    //JTextField text = new JTextField(16);
    //content.add(yourInputField);
    /*p.add(text);
    String x = text.getText();

    string agestring = tField.setText();

    if (agestring == null || agestring.length() == 0)
    {
    JOptionPane
    return;
    }
    double age = double.parseDouble(agestring);
    hr = aset
    label1.setText("Your heart rate is " + hr)
    */

    }
    });
    }

    }

  2. #2
    faisalcmpm is offline Member
    Join Date
    Feb 2009
    Posts
    22
    Rep Power
    0

    Default

    Please remove commented lines.
    Also would you please tell u whats the real issue

Posting Permissions

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