Need help displaying name of window

Started by
1 comment, last by capn_midnight 11 years, 2 months ago

package falling;
public class window {
this.setTitle("Falling");
}
if(false)
{
    this.setExtendedState(this.MAXIMIZED_BOTH)

}
else
{
    this.setSize (1024, 768)
this.setLocationRelativeTo(null)
this.setResizable(false)
}

Netbeans is saying that this.setTitle("Falling") expects a class,method or enum. However i thought i already specified that is was public class window in package falling. Am i forgetting something?

Advertisement


package falling; <- this is fine

// Note, convention is to use a Capital letter for class names
// Window, not window.  Not an error, just what everyone does 
public class window { <- start window class definition


   this.setTitle("Falling"); <- this code isn't in the right place.  Try a constructor or a method.

} <- end window class definition

// This code below the comment doesn't belong to the window class.  It doesn't belong to any class.
// Fix this :)
if(false)
{
   this.setExtendedState(this.MAXIMIZED_BOTH)  <- somthing missing here
 
}
else
{
   this.setSize (1024, 768) <- somthing missing here
   this.setLocationRelativeTo(null) <- somthing missing here
   this.setResizable(false) <- somthing missing here
}

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

You should also probably not name it Window, because that is a pretty common name for the base Window class in most windowing toolkits. Packages will help avoid name collisions, but it's still a pain in the ass.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

This topic is closed to new replies.

Advertisement