Results 1 to 2 of 2
  1. #1
    masberry is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default <identifier> expected, illegal start of type

    Hi, i'm new to java and trying to make a simple program with image icon embedded in checkbox but the program always show
    <identifier> expected
    illegal start of type
    ')' expected
    ';' expected on line 15

    Below is my program:

    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import java.applet.Applet;

    // To run this program the classname must be the same with its filename
    public class Vote1 extends JFrame implements ActionListener, ItemListener

    //This are the variables i use in the program
    Label lbl1 = new Label("WELCOME");

    Label chairman = new Label("CHAIRMAN");
    Checkbox cnd1 = new Checkbox("A");
    cnd1.setIcon(new ImageIcon("usIcon.gif"));
    Checkbox cnd2 = new Checkbox("B");

    Label secretary = new Label("SECRETARY");
    Checkbox cnd3 = new Checkbox("C");
    Checkbox cnd4 = new Checkbox("D");

    Label treasurer = new Label("TREASURER");
    Checkbox cnd5 = new Checkbox("E");
    Checkbox cnd6 = new Checkbox("F");

    Button smit = new Button("Submit");


    plz advice, thx..

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Rep Power


    You can't put
    Java Code:
    cnd1.setIcon(new ImageIcon("usIcon.gif"));
    outside of a method. Only declarations are allowed outside a method.

Similar Threads

  1. identifier expected
    By tlouvierre in forum New To Java
    Replies: 4
    Last Post: 05-28-2009, 01:11 AM
  2. <identifier> expected, I'm stuck
    By UnderpaidWorker in forum New To Java
    Replies: 18
    Last Post: 12-13-2008, 06:14 AM
  3. getting identifier expected error . help me !
    By victorkeath in forum New To Java
    Replies: 3
    Last Post: 11-07-2008, 06:49 PM
  4. Replies: 9
    Last Post: 08-08-2007, 08:16 PM
  5. Error: <identifier> expected
    By barney in forum AWT / Swing
    Replies: 2
    Last Post: 07-31-2007, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts