5 Replies - 541 Views - Last Post: 27 June 2012 - 05:10 PM Rate Topic: -----

#1 Utael  Icon User is offline

  • D.I.C Head

Reputation: 55
  • View blog
  • Posts: 210
  • Joined: 12-December 11

notepad app throwing class, interface, or enum expected exception

Posted 27 June 2012 - 12:16 AM

I go to compile my code and it throws this exception.
"class, interface, or enum expected"

this is the code that's throwing the exception
public static void main(String args[]) {
    Notepad app = new Notepad();
    app.setVisible(true);
}

This post has been edited by Utael: 27 June 2012 - 12:17 AM

Is This A Good Question/Topic? 0
  • +

Replies To: notepad app throwing class, interface, or enum expected exception

#2 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,055
  • Joined: 28-December 10

Re: notepad app throwing class, interface, or enum expected exception

Posted 27 June 2012 - 01:56 AM

That's the whole class?
Was This Post Helpful? 1
  • +
  • -

#3 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2013
  • View blog
  • Posts: 3,038
  • Joined: 21-June 11

Re: notepad app throwing class, interface, or enum expected exception

Posted 27 June 2012 - 02:03 AM

"class, interface, or enum expected" is a compilation error, not an exception. It's telling you that it's expecting a definition of a class, interface or enum - not a method definition.

Method definitions go inside class (or enum) definitions. You can't have a .java file that just contains a method definition without a class or enum around it.
Was This Post Helpful? 1
  • +
  • -

#4 Utael  Icon User is offline

  • D.I.C Head

Reputation: 55
  • View blog
  • Posts: 210
  • Joined: 12-December 11

Re: notepad app throwing class, interface, or enum expected exception

Posted 27 June 2012 - 12:35 PM

Okay, figured out what the issue was, I was thinking it was going to be something stupid.

Now when i compile its telling me that "font is not public in java.awt.Component; cannot be accessed from outside package

I've tried importing java.awt.Component directly in my import section.

this.textArea.setFont(new Font("Century Gothic", font.BOLD, 12));

Was This Post Helpful? 0
  • +
  • -

#5 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2013
  • View blog
  • Posts: 3,038
  • Joined: 21-June 11

Re: notepad app throwing class, interface, or enum expected exception

Posted 27 June 2012 - 12:54 PM

It's Font.bold with a capital F. You wrote font.bold.
Was This Post Helpful? 0
  • +
  • -

#6 Utael  Icon User is offline

  • D.I.C Head

Reputation: 55
  • View blog
  • Posts: 210
  • Joined: 12-December 11

Re: notepad app throwing class, interface, or enum expected exception

Posted 27 June 2012 - 05:10 PM

Again something basic thank you very much ill take some more time to learn.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1