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

    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");
    TeachersGradebook2.java:17: <identifier> expected
    panelHolder = new JPanel(new CardLayout());
    ^
    TeachersGradebook2.java:18: <identifier> expected
    panelHolder.add(mainMenu, "0");
    ^[/CODE]

    any ideas?

    Thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    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
    Posts
    63
    Rep Power
    0

    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, 05: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, 05:14 AM
  4. getting identifier expected error . help me !
    By victorkeath in forum New To Java
    Replies: 3
    Last Post: 11-07-2008, 05: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
  •