Ich folgte diesem aber ich weiß nicht, wo ist der Fehler die folgenden 2 Klasse erklären jede Sache, weil es nur zwei Klassen ist, habe ich versucht, das Tutorial wieder zu sehen, aber immer noch habe ich den Fehler nicht gefundenArrayIndexOutOfBoundsException 2D Spiel Entwicklung
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gameofthrones;
import java.awt.*;
import javax.swing.*;
/**
*
* @author issba
*/
public class ClassOGP extends JFrame{
boolean fse =false;
int fsm = 0;
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1];
public ClassOGP(String title,int width,int height){
setTitle(title);
setSize(width,height);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
}
private void setfullscreen(){
switch(fsm){
case 0:
System.out.println("No fullscreen");
setUndecorated(false);
break;
case 1:
setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
break;
case 2:
device.setFullScreenWindow(this);
setUndecorated(true);
break;
}
}
public void setFullscreen(int fsnm){
fse = true;
if(fsm <= 2){
this.fsm = fsnm;
setfullscreen();
}else{
System.err.println("Error " + fsnm + " is not supported");
}
}
}
Dies ist die Hauptklasse, es gibt nicht viel Code drin.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gameofthrones;
/**
*
* @author issba
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
ClassOGP frame = new ClassOGP("Game Of thrones",1280,720);
frame.setFullscreen(1);
frame.setVisible(true);
}
}
die Fehlermeldung hier
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at gameofthrones.ClassOGP.<init>(ClassOGP.java:18)
at gameofthrones.Main.main(Main.java:20)
C:\Users\issba\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
dieser Zeile:. 'Graphics device = GraphicsEnvironment.getLocalGraphicsEnvironment() getScreenDevices() [1];' wirft den Fehler. Versuchen Sie, die "1" zu einer "0" zu ändern. –
@JonnyHenly Recht Danke Mann, wenn Sie möchten, können Sie es als Antwort auch können Sie enplane die verschiedenen PLZ –
@Siddharth danke Mann für die Bearbeitung –