3 Replies - 1158 Views - Last Post: 17 May 2010 - 10:56 PM Rate Topic: -----

#1 groman88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 18-December 09

keyword "this" as method argument

Posted 17 May 2010 - 06:57 PM

I ran into this and I am not sure what the keyword this as the method argument signifies. I only posted parted of the code but I will post the entire thing if needed. I know what the keyword this does, but I have never seen it as a method argument. Also, I believe it is of JFrame type

void SimpleScreenManager.setFullScreen(DisplayMode displayMode, JFrame window)


public void run(DisplayMode displayMode) {
        setBackground(Color.white);
        setForeground(Color.red);
        setFont(new Font("Dialog", Font.PLAIN, 30));

        // simple interface to change the display to full-screen mode
        SimpleScreenManager screen = new SimpleScreenManager();
        try {
            screen.setFullScreen(displayMode, this);
            try {
                Thread.sleep(DEMO_TIME);
            }
            catch (InterruptedException ex) { }
        }
        // guarantees that the screen will always be restored
        finally {
             screen.restoreScreen();
        }
    }




Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: keyword "this" as method argument

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3116
  • View blog
  • Posts: 19,154
  • Joined: 14-September 07

Re: keyword "this" as method argument

Posted 17 May 2010 - 07:50 PM

'this' refers to the current instance of whatever class that is a part of
Was This Post Helpful? 1
  • +
  • -

#3 immeraufdemhund  Icon User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: keyword "this" as method argument

Posted 17 May 2010 - 07:51 PM

most likely the class that is called extends JFrame. so it's passing itself to screen.setFullScreen().. as in it needs to be what is displayed on the full screen.. i think.
Was This Post Helpful? 1
  • +
  • -

#4 pdkharkar  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 63
  • View blog
  • Posts: 345
  • Joined: 19-January 09

Re: keyword "this" as method argument

Posted 17 May 2010 - 10:56 PM

you should read the tutorial "this" keyword in java for better understanding
this is in my signature
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1