im not sure whats wrong with my code but i need help fixing it. I need to get the hypotenuse of sides a and b and i am having problems in the code.
// The "Components" class. import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class ButtonDemo extends JFrame implements ActionListener { // Declare objects JLabel label; JLabel label2; JButton button1, button2; JTextField text; JTextField text2; public ButtonDemo () { super ("ButtonDemo"); // Set up the frame this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); this.setBounds (300, 300, 200, 350); // Create objects JPanel content = new JPanel(); label = new JLabel ("10",JLabel.CENTER); label2 = new JLabel ("20",JLabel.CENTER); text = new JTextField (10); text2 = new JTextField (10); button1 = new JButton ("Calculate"); button2 = new JButton ("Done"); // Add contents content.add (label); content.add (label2); content.add (button1); content.add (button2); content.add (text); content.add (text2); // Add listeners button1.addActionListener (this); button2.addActionListener (this); text.addActionListener (this); // Show the contents this.setContentPane (content); this.setVisible (true); } public void actionPerformed (ActionEvent e) { if (e.getSource () == button1) { a = Double.parseDouble (text1.getText()); } double a = Math.sqrt(a*a+b*b); { a = 0; // just make it zero for simplicity } { b= Double.parseDouble (text1.getText()); } double b = Math.sqrt(a*a+b*b); { b = 0; // just make it zero for simplicity } double c = Math.sqrt(a*a+b*b); { label.setText ("The hyp is:" + c); } } else if (e.getSource () == button2) { label.setText ("Exit."); System.exit(0); } } // main method } // Components class