import java.awt.*;
import javax.swing.*;

JPanel middlePanel = new JPanel();
    middlePanel.setLayout(new GridBagLayout());

    GridBagConstraints cons = new GridBagContraints();
    cons.weightx = 1.0;
    cons.weighty = 1.0;
    middlePanel.setBorder(new TitledBorder(new EtchedBorder(),"Display Area"));

When i use this code snippet(this is just a rough code snippet) i get errors like "can not find symbol GridBagContraints" and "can not find symbol TitledBorder","can not find symbol EtchedBorder". How to fix it?

TitledBorder is because you don't import it. It's javax.swing.border.TitledBorder, so importing javax.swing.* won't import it.

As for java.awt.GridBagConstraints, I don't know why that is giving a problem when you import java.awt.*