Click here to Skip to main content
13,052,163 members (41,401 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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?
Posted 15-Jun-13 19:48pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The error told you what is the issue. You are using
GridBagConstraints cons = new GridBagContraints();

instead of
GridBagConstraints cons = new GridBagConstraints();

And again in case of TitledBorder you have to import the required api
import javax.swing.border.TitledBorder
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You are missing an import spec for GridBagConstraints, which seems to be in "java.awt.GridBagConstraints". If you are using Eclipse, it will tell you this if you hover over the statement with the error and will optionally insert the correct include for you.

Same again (similar solution) for TitledBorder.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Thanks for helping..Its solved now. Imported


And made the spelling correct for GridBagConstraints cons = new **GridBagConstraints()**;

instead of GridBagConstraints cons = new **GridBagContraints()**;

Thanks again..":)"



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 17 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100