import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Font;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.JToolTip;
import javax.swing.JTextArea;
/
public class Swing extends JFrame implements ActionListener

import javax.swing.JFrame;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Font;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.JToolTip;
import javax.swing.JTextArea;   

JPanel P1,P2,P3,P4;
JLabel L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11;
JTextArea T1;
JTextField T2,T3,T4,T5,T6;
JButton B1,B2,B3,B4;
Font F1,F2;
/
public Swing()

{

    setTitle("Chick Your Health");
    setSize(450,400);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    F1=new Font("Cambria",Font.BOLD,20);
    F2=new Font("Calibri",Font.BOLD,20);

        P1=new JPanel();
        P1.setLayout(new GridLayout(5,2));


            L1=new JLabel("Name");
            L1.setFont(F1);
            P1.add(L1);
            T2=new JTextField(20);
            T2.setFont(F2);
            P1.add(T2);

            L2=new JLabel("Age");
            L2.setFont(F1);
            P1.add(L2);
            T3=new JTextField(20);
            T3.setFont(F2);
            P1.add(T3);

            L3=new JLabel("Weight");
            L3.setFont(F1);
            P1.add(L3);
            T4=new JTextField(20);
            T4.setFont(F2);
            P1.add(T4);

            L4=new JLabel("Hight");
            L4.setFont(F1);
            P1.add(L4);
            T5=new JTextField(20);
            T5.setFont(F2);
            P1.add(T5);

            L5=new JLabel("Blod Type");
            L5.setFont(F1);
            P1.add(L5);
            T5=new JTextField(20);
            T5.setFont(F2);
            P1.add(T5);

            B1=new JButton("Calculate");
            B1.addActionListener(this);
            B1.setFont(F1);
            B1.setToolTipText("To Calculate Your BMI");
            P1.add(B1);


            TitledBorder tb1=new TitledBorder("Input");
            tb1.setTitleJustification(TitledBorder.LEFT);
            tb1.setTitlePosition(TitledBorder.TOP);
            P1.setBorder(tb1);

            add(P1,BorderLayout.NORTH);

            P2=new JPanel();
            P2.setLayout(new GridLayout(2,2));

            L6=new JLabel("BMI");
            L6.setFont(F1);
            P2.add(L6);
            T6=new JTextField(20);
            T6.setFont(F2);
            P2.add(T6);
            L8=new JLabel("");

            TitledBorder tb2=new TitledBorder("YourBMI");
            tb2.setTitleJustification(TitledBorder.LEFT);
            tb1.setTitlePosition(TitledBorder.TOP);
            P2.setBorder(tb2);

            add (P2,BorderLayout.CENTER);

            P3=new JPanel();
            P3.setLayout(new GridLayout(1,2));
            B2=new JButton("Show");
            B2.addActionListener(this);
            B2.setFont(F1);
            B2.setToolTipText("To Show Your Information");
            P3.add(B2);
            L7=new JLabel("");
            L7.setFont(F1);
            P3.add(L7);
            L8=new JLabel("");
            L8.setFont(F1);
            P3.add(L8);
            L9=new JLabel("");
            L9.setFont(F1);
            P3.add(L9);

            add(P3,BorderLayout.WEST);

            P4=new JPanel();
            P4.setLayout(new FlowLayout());
            B3=new JButton("Clear");
            B3.addActionListener(this);
            B3.setFont(F1);
            P4.add(B3);
            B4=new JButton("Close");
            B4.addActionListener(this);
            B4.setFont(F1);
            P4.add(B4);

            add(P4,BorderLayout.SOUTH); 

        }
        public void actionPerformed(ActionEvent e)
        {
            String msg=e.getActionCommand();

            Double W=Double.parseDouble(T4.getText());
            Double H=Double.parseDouble(T5.getText());

            if(msg.equalsIgnoreCase("Calculate"))
            {
                try
                {
                    if(W<=0)throw new MyException("Weight should be greater than zero");
                    if(H<=0)throw new MyException("Hight should be greater than zero");
                    Double BMI=W/(H*H);
                    T6.setText(Double.toString(BMI));
                }
                catch(MyException g)
                {
                    T6.setText(g.getMessage());
                }
                if(MBI<18.5)
                    L11.setText("You are under weight");
                else if((MBI<=24.9)||(MBI>=15.5))
                    L11.setText("Your wieght is normal");
                else if(MBI>24.9)
                    L11.setText("You are over wieght");
            }
        }
        if(msg.equalsIgnoreCase("Show"))
        {
            L7.setText("Your Name: "+T2.getText());
            L8.setText("Your Age: "+T3.getText());
            L9.setText("Your MBI: "+T6.getText());
        }
        if(msg.equalsIgnoreCase("Clear"))
        {
            T2.setText("");
            T3.setText("");
            T4.setText("");
            T5.setText("");
            T6.setText("");
        }
        if(msg.equalsIgnoreCase("Close"))
        {
            System.Exit(0);
        }
}           

the errors are :

C:\Users\hp\Documents\Swing.java:171: illegal start of type
            if(msg.equalsIgnoreCase("Show"))
            ^
C:\Users\hp\Documents\Swing.java:171: <identifier> expected
            if(msg.equalsIgnoreCase("Show"))
                                   ^
C:\Users\hp\Documents\Swing.java:171: illegal start of type
            if(msg.equalsIgnoreCase("Show"))
                                    ^
C:\Users\hp\Documents\Swing.java:177: illegal start of type
            if(msg.equalsIgnoreCase("Clear"))
            ^
C:\Users\hp\Documents\Swing.java:177: <identifier> expected
            if(msg.equalsIgnoreCase("Clear"))
                                   ^
C:\Users\hp\Documents\Swing.java:177: illegal start of type
            if(msg.equalsIgnoreCase("Clear"))
                                    ^
C:\Users\hp\Documents\Swing.java:185: illegal start of type
            if(msg.equalsIgnoreCase("Close"))
            ^
C:\Users\hp\Documents\Swing.java:185: <identifier> expected
            if(msg.equalsIgnoreCase("Close"))
                                   ^
C:\Users\hp\Documents\Swing.java:185: illegal start of type
            if(msg.equalsIgnoreCase("Close"))
                                    ^
9 errors

Process completed.

What is in line 24 for (forward slash)?

Another part is that you close/end your actionPerformed method (}) on line 168. You can't start with if again afterward.

What you need to do is to properly indent your code!

Check you code first if statement is repeated in the program cases that you have been declared that is the reason of errors because it is case sensitive language.

Check you code first if statement is repeated in the program cases that you have been declared that is the reason of errors because it is case sensitive language.

Huh? Please carefully look at the error message; especially, look at the first line of error message because it is usually where the error occurs. Any following errors may be resolved if you fix the first one. In this case, the OP starts using the if statement outside a method scope!

By the way, repeating if statement is valid even though it may be replaced with if-else if-else statement for more efficiency and readability. If there is any case-sensitive error as you said, the error would very likely be 'cannot find symbol' instead. Your answer is invalid.

not to mention, I don't see any problems with the case sensitivity in his code.
checking the closing brackets, as Taywin mentioned, 'll do the job.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.