Results 1 to 3 of 3
  1. #1
    jr2648 is offline Member
    Join Date
    Nov 2010
    Rep Power

    Default Identifier expected

    Currently, I'm designing a gui program that incorporates the use of Cardlayout. I am just beginning, but I can't seem to compile passed this first portion of code.

    Java Code:
    public class TeachersGradebook2{
    	JPanel panelholder; // Panel that contains the cards
    	JPanel mainMenu = new JPanel(); // Main Menu
    	JPanel addStudent = new JPanel(); // Add a student Menu
    	panelHolder = new JPanel(new CardLayout());
    	panelHolder.add(mainMenu, "0");
    	panelHolder.add(addStudent, "1"); <identifier> expected
    panelHolder = new JPanel(new CardLayout());
    ^ <identifier> expected
    panelHolder.add(mainMenu, "0");

    any ideas?


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    You're calling code that can't be stuck out naked in the class. Rather it needs to be in a constructor or method or initialization block.

  3. #3
    hosscomp is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default Identifier expected

    Also, panelHolder was delcared as panelholder. Not the same.

Similar Threads

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