Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is what the error looks like

C#
pledgeform2.java:8: error: '{' expected
public class Pledgeform2.java extends javax.swing.JFrame
                        ^
1 error




I keep getting an error message indicating '{' expected on line 8 in bold. I have been trying to figure out what and where the error is. Please help!!!

Java
package Pledgeform.java;
import javax.swing.JFrame;
import javax.swing.*;
public class Pledgeform2.java extends javax.swing.JFrame	
	public Pledgeform2() {
        initComponents();
    };    
    JFrame guiFrame = new JFrame();
    JPanel panel_1;
    JLabel label_1;
    JLabel label_2;
    ButtonGroup cbg;
    JRadioButton radio_1;
    JRadioButton radio_2;
    JRadioButton radio_3;
    JRadioButton radio_4;
    JList list_1;
    JScrollPane sp_list_1;
    JLabel label_3;
	 
    public static void main(String args[]) {
    
    }
    public Pledgeform2() {
        Pledgeform2Layout customLayout = new Pledgeform2Layout();
        panel_1 = new JPanel();    
        label_1 = new JLabel("Last Name");
        label_2 = new JLabel("First Name");
        cbg = new ButtonGroup();
        radio_1 = new JRadioButton("$10.00", false);
        cbg.add(radio_1);
        radio_2 = new JRadioButton("$20.00", false);
        cbg.add(radio_2);
        radio_3 = new JRadioButton("$50.00", false);
        cbg.add(radio_3);
        radio_4 = new JRadioButton("Other Amount", false);
        cbg.add(radio_4);       
        DefaultListModel listModel_list_1 = new DefaultListModel();
        listModel_list_1.addElement("Red Cross");
        listModel_list_1.addElement("Salvation Army");
        listModel_list_1.addElement("Humane Society");
        listModel_list_1.addElement("Poor UofP Students");
        list_1 = new JList(listModel_list_1);
        sp_list_1 = new JScrollPane(list_1);
        label_3 = new JLabel("Call 1-800-555-6789 if pledging other amount");
        /**
         * @param args the command line arguments
         */
    }
}
Posted
Updated 21-Aug-20 16:26pm
v3
Comments
TorstenH. 4-Jun-13 4:33am    
Please let the IDE's editor show line numbers.
That makes it easier for you to see where the problem is.
Garde333 4-Jun-13 4:39am    
Ok thank you very much.... I tryed that and I'm still getting the same error message on the same line....

The error is obvious. See in your code carefully, you missed { after creating class. Try this:
Java
public class Pledgeform2.java extends javax.swing.JFrame
{//This was missed	
	public Pledgeform2() {
        initComponents();
    };    
    JFrame guiFrame = new JFrame();
    JPanel panel_1;
    JLabel label_1;
    JLabel label_2;
    ButtonGroup cbg;
    JRadioButton radio_1;
    JRadioButton radio_2;
    JRadioButton radio_3;
    JRadioButton radio_4;
    JList list_1;
    JScrollPane sp_list_1;
    JLabel label_3;
	 
    public static void main(String args[]) {
    
    }
    public Pledgeform2() {
        Pledgeform2Layout customLayout = new Pledgeform2Layout();
        panel_1 = new JPanel();    
        label_1 = new JLabel("Last Name");
        label_2 = new JLabel("First Name");
        cbg = new ButtonGroup();
        radio_1 = new JRadioButton("$10.00", false);
        cbg.add(radio_1);
        radio_2 = new JRadioButton("$20.00", false);
        cbg.add(radio_2);
        radio_3 = new JRadioButton("$50.00", false);
        cbg.add(radio_3);
        radio_4 = new JRadioButton("Other Amount", false);
        cbg.add(radio_4);       
        DefaultListModel listModel_list_1 = new DefaultListModel();
        listModel_list_1.addElement("Red Cross");
        listModel_list_1.addElement("Salvation Army");
        listModel_list_1.addElement("Humane Society");
        listModel_list_1.addElement("Poor UofP Students");
        list_1 = new JList(listModel_list_1);
        sp_list_1 = new JScrollPane(list_1);
        label_3 = new JLabel("Call 1-800-555-6789 if pledging other amount");
        /**
         * @param args the command line arguments
         */
    }
}



--Amit
 
Share this answer
 
Your class name is illegal, it should just be Pledgeform2, plus you need the { before the class details. You also have a constructor for the class inside your main method, plus most of your variables have not been typed on their declarations. I think you would be well advised to study this tutorial[^].
 
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