We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Fullscreen on 2nd screen/projector.
Page Index Toggle Pages: 1
Fullscreen on 2nd screen/projector. (Read 4986 times)
Fullscreen on 2nd screen/projector.
Jul 25th, 2007, 1:16am
 
hello. i'd like to run my app in fullscreen at my 2nd screen/projector, and just be able to work normaly on my primary screen. i'm on a macbook. any suggestions=?

Slm
Re: Fullscreen on 2nd screen/projector.
Reply #1 - Jul 25th, 2007, 5:04pm
 
The easiest way to do this is simply to turn off the window frames and position it at the top left corner of your second screen.

I have blogged this technique before, the code looks like this:

Code:
import processing.opengl.*;

void setup(){
size(400,400,OPENGL);
background(0);

// set location - needs to be in setup()
// set x parameter depending on the resolution of your 1st screen
frame.setLocation(1024,0);
}

void draw(){
stroke(255);
line(0,0,200,200);
}

public void init() {
frame.setUndecorated(true); // works.

// call PApplet.init() to take care of business
super.init();
}


You could of course detect the size of your screens in code, so you wouldn't have to set it manually.
Re: Fullscreen on 2nd screen/projector.
Reply #2 - Jul 25th, 2007, 5:37pm
 
thanks. works great.
is there any other more advanced way?

Slm
Re: Fullscreen on 2nd screen/projector.
Reply #3 - Jul 25th, 2007, 6:18pm
 
Not sure what you mean by "more advanced", but in general this would be the normal way to have one window cover one screen while the other screen functions as normal. You can't use the Java fullscreen mode, since that would take over both screens completely.

If you wanted to make sure the application window is always on top of everything else, you could always add the following after the setLocation command:

Code:
frame.setAlwaysOnTop(false); 

Re: Fullscreen on 2nd screen/projector.
Reply #4 - May 11th, 2009, 9:11pm
 
I tried with Processing 1.0.3 on Windows XP and got this error:

java.awt.IllegalComponentStateException: The frame is displayable.
     at java.awt.Frame.setUndecorated(Unknown Source)
     at color_organ_lite_dualmon.init(color_organ_lite_dualmon.java:153)
     at processing.core.PApplet.main(PApplet.java:6566)

Any clues?
Re: Fullscreen on 2nd screen/projector.
Reply #5 - May 12th, 2009, 11:18am
 
I found something I'd like to share with you...
Good news: I found the solution to the cryptic error message "The frame is displayable" -- simply add this
frame.removeNotify();
will change it to non-displayable and thus remove the compilation error.  (You may need to make it displayable again after frame.setUndecorated(true)Wink
Bad news:
   frame.setLocation(1020,200);  // no effect
I am not able to get it to change the display location no matter what x y location I use.
Anyone knows about the changes since 2007 that can shine a light on this issue?
Re: Fullscreen on 2nd screen/projector.
Reply #6 - May 12th, 2009, 5:00pm
 
Good news: I found the other part of the answer... It now works for me -- its not easy to find the answer, so I thought I'll share it...
It turns out the requirements for frame.setLocation(x,y) is different dependent on which mode -- most examples uses OPENGL which explains why people who used it said it works.  I used P2D, and I got frame.setLocation(x,y) to work inside draw()...
Re: Fullscreen on 2nd screen/projector.
Reply #7 - May 13th, 2009, 4:03am
 
this has been working so far for me (processing 101)

if you overload init()

void init(){
 frame.dispose();  
 frame.setUndecorated(true);
 super.init();  
}

then in setup(), you can after size()
 //set at second screen  
 frame.setLocation(1280,0);

Re: Fullscreen on 2nd screen/projector.
Reply #8 - Aug 27th, 2009, 3:10am
 
For me, using OPENGL, frame.setLocation wouldn't work until I moved it into draw() - it would just draw a grey rectangle. My init method looks like this:
Code:
public void init() {
frame.removeNotify();
frame.setUndecorated(true);
frame.addNotify();
// call PApplet.init() to take care of business
super.init();
}
Re: Fullscreen on 2nd screen/projector.
Reply #9 - Feb 4th, 2010, 3:34pm
 
This solution worked pretty well for me, but I wanted to make my code automatically detect the second screen's location and dimensions. This required using GraphicsConfiguration or GraphicsDevice.

I modified some code I found from Java's 2D API, (sorry, I can't post the link since this is my first post, but just google "Rendering in a Multi-Screen Environment" and it should come up first.)

Then I combined it with some some of the code posted above. It works pretty well, as long as you don't change the screen resolution or positioning while the applet is running Smiley

Also, I'm not using opengl, so I don't know what would change if you were.

Code:
Rectangle monitor = new Rectangle();

void setup() {
 // Get second screen details and save as Rectangle monitor
 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 GraphicsDevice[] gs = ge.getScreenDevices();
 // gs[1] gets the *second* screen. gs[0] would get the primary screen
 GraphicsDevice gd = gs[1];
 GraphicsConfiguration[] gc = gd.getConfigurations();
 monitor = gc[0].getBounds();
 
 println(monitor.x + " " + monitor.y + " " + monitor.width + " " + monitor.height);
 size(monitor.width, monitor.height);
 background(0);
}

void draw() {
 frame.setLocation(monitor.x, monitor.y);
 frame.setAlwaysOnTop(true);
 stroke(255);
 line(0,0,width/2,height/2);
}  

public void init() {
 frame.removeNotify();
 frame.setUndecorated(true);
 super.init();
}

Hope this helps someone!
Page Index Toggle Pages: 1