Keyword THIS usuage in this code
Code:
private GraphicsDevice device;
SimpleScreenManager(){
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
device = ge.getDefaultScreenDevice();
public void setFullScreen(DisplayMode displayMode, JFrame window){
window.setUndecorated(true);
window.setResizable(false);
device.setFullScreenWindow(window);
//test if displayMode has parameters passed to it and change mode is supported
if(displayMode != null && device.isDisplayChangeSupported()){
try{
device.setDisplayMode(displayMode);
}
catch (IllegalArgumentException ex){
//ignore illegal mode for this device
}
}
public void run(DisplayMode displayMode){
setBackground(Color.blue);
setForeground(Color.white);
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.
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.
db