0

so I'm making a program with a "controller" and two display screen's, kinda like Powerpoint when you press slideshow its open on the second screen in fullscreen. I have manage to do it with only two screens but every time I try with three I get a null pointer. here is my code:

import javax.imageio.ImageIO;

public class Program extends Canvas implements Runnable{
private static final long serialVersionUID = -7579474834886333524L;

private Thread thread;
private boolean isRunning = false;

private Måler måler;
private MålerLille målerlille;

public Program() {
    new Controller();

    målerlille = new MålerLille(1920, 1080, "screen3", this);
    måler = new Måler(1920, 1080, "screen2", this);

    GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();

    gs[2].setFullScreenWindow(MålerLille.frameML);
    gs[1].setFullScreenWindow(Måler.frame);
Cyber Progs
  • 3,656
  • 3
  • 30
  • 39
  • 1
    It is easier for us if you name your classes in English. Furthermore, your code doesn't show the relevant parts. – Thomas Böhm Oct 30 '17 at 22:05
  • Arrays are `0` indexed, what are the values of `gs`? I'd be careful blindly accessing indicies – MadProgrammer Oct 30 '17 at 22:07
  • @ThomasBöhm it doesn't make that much difference what language it's in: there's only two classes, and one is "clearly" (...) a "little" version of the other. An NPE is a NPE. What is more relevant is an indication of the line on which the NPE occurs. – Andy Turner Oct 30 '17 at 22:08
  • @MadProgrammer im not 100% sure after that I copied the code from another thread on stackoverflow but I think it is the screen device so 0 Is my main screen 1 is my second screen and 2 is my third screen. – Jonas Lee Lee Oct 31 '17 at 01:04
  • @JonasLeeLee Don't guess, printing the length of he array, print the contents to see what they can – MadProgrammer Oct 31 '17 at 01:11
  • @Madprogrammer how do I do that? im pretty new to programming – Jonas Lee Lee Oct 31 '17 at 10:11

0 Answers0