Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java AWT
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 20:48pm
sash_kp367
Rate this: bad
good
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
  Permalink  
v2
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Thanks for helping..Its solved now. Imported
 
javax.swing.border.TitledBorder
javax.swing.border.EtchedBorder
 
And made the spelling correct for GridBagConstraints cons = new **GridBagConstraints()**;
 
instead of GridBagConstraints cons = new **GridBagContraints()**;

Thanks again.."Smile | :) "
 
@H.Brydon
 
@Shubhashish_Mandal
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 17 Jun 2013
Copyright © CodeProject, 1999-2014
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