Guten Tag zusammen,
ich habe momentan das Problem, dass mir Eclipse immer den Selben Fehler ausspuckt, und zwar "AWT-EventQueue-0"..... Ich habe gegoogelt ohne Ende, kann aber nicht verstehen warum ich immernoch diesen Fehler bekomme
Alles andere funktioniert einwandfrei, nur wenn ich versuche diese for-Schleife in Zeile 33 aus zu führen weigert Eclipse sich... Danke schonmal für Tips
Mein Code:
Die Fehlermeldung:
ich habe momentan das Problem, dass mir Eclipse immer den Selben Fehler ausspuckt, und zwar "AWT-EventQueue-0"..... Ich habe gegoogelt ohne Ende, kann aber nicht verstehen warum ich immernoch diesen Fehler bekomme
Alles andere funktioniert einwandfrei, nur wenn ich versuche diese for-Schleife in Zeile 33 aus zu führen weigert Eclipse sich... Danke schonmal für Tips
Mein Code:
Java:
public class Main {
static Gui gui = new Gui();
static int windowSizeX = 530;
static int windowSizeY = 600;
public static String Gedicht;
String[] Words;
String[] WordsTemp;
int[] WordsLength;
public static void main(String[] args) {
gui.openWindow(windowSizeX, windowSizeY);
}
public void TestGedicht() {
Words = Gedicht.split(" ");
WordsTemp = new String[Words.length];
for(int i = 0; i < Words.length; i++) {
Words[i] = removeUnwanted(Words[i]);
}
OverwriteArrays();
WordsLength = new int[Words.length];
for(int i = 0; i < Words.length; i++) {
WordsLength[i] = Words[i].length();
}
for(int i = 0; i < Words.length; i++) {
System.out.println(Words[i] + " " + WordsLength[i]);
}
}
public String removeUnwanted(String a) {
for(int i = 0; i < a.length(); i++) {
a = a.replace(",", "");
a = a.replace(".", "");
a = a.replace("–", "");
a = a.replace("?", "");
a = a.replace(":", "");
a = a.replace(";", "");
}
return a;
}
public void OverwriteArrays() {
for(int i = 0; i < Words.length; i++) {
if(!Words[i].equals("")) {
WordsTemp[i] = Words[i];
}
}
Words = WordsTemp;
}
}
Die Fehlermeldung:
Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Main.TestGedicht(Main.java:33)
at Gui$1.actionPerformed(Gui.java:36)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)