Results 1 to 2 of 2
  1. #1
    Fingerz is offline Member
    Join Date
    Jan 2011
    Rep Power

    Default Keyword THIS usuage in this code

    Java Code:
    private GraphicsDevice device;
    		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    		device = ge.getDefaultScreenDevice();
    public void setFullScreen(DisplayMode displayMode, JFrame window){
    		//test if displayMode has parameters passed to it and change mode is supported
    		if(displayMode != null && device.isDisplayChangeSupported()){
    			catch (IllegalArgumentException ex){
    				//ignore illegal mode for this device
                    public void run(DisplayMode displayMode){
    		setFont(new Font("Dialog", Font.PLAIN, 24));
    		SimpleScreenManager screen = new SimpleScreenManager();
    		try	{
    			screen.setFullScreen(displayMode, this);
    			try	{
    Im getting this code from Developing Games in Java page 28-39
    Couple things that are confusing me.
    1)screen.setFullScreen(displayMode,this) What is THIS a reference to.
    2) the setFore and Background lines pertain to a Windowed object such as window.setBackground() where is that coming from by itself.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Keyword THIS usuage in this code

    Using the this Keyword (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Don't try to run before you can walk. First learn Java, and then progress to games. And never use code copied from elsewhere without understanding all of it.

    Since the problem has nothing whatsoever to do with Java2D, I'm moving the thread to New to Java.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Keyword : volatile
    By peiceonly in forum Advanced Java
    Replies: 13
    Last Post: 11-17-2010, 12:47 PM
  2. Using 'this' keyword in constructor
    By kudwn in forum New To Java
    Replies: 5
    Last Post: 10-11-2010, 09:47 AM
  3. this keyword
    By coltragon in forum New To Java
    Replies: 10
    Last Post: 03-01-2010, 09:20 AM
  4. what is the use of final keyword
    By sumanandjesus in forum Advanced Java
    Replies: 9
    Last Post: 03-27-2009, 12:50 PM
  5. Use of this keyword
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-18-2007, 07:32 PM

Posting Permissions

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