Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
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

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..":)"

@H.Brydon

@Shubhashish_Mandal
 
Share this answer
 
The error told you what is the issue. You are using
Java
GridBagConstraints cons = new GridBagContraints();


instead of
Java
GridBagConstraints cons = new GridBagConstraints();


And again in case of TitledBorder you have to import the required api
Java
import javax.swing.border.TitledBorder
 
Share this answer
 
v2
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900