ArrayList-Error Index: 1 Size:1 - Bitte um Hilfe

Jats

Aktives Mitglied
Hey, ich hab mir ein kleines Programm geschrieben und ich arbeite mit einer ArrayList.
Da wird nach klick auf dem Button in jedem Durchgang der for-Schleife ein String dazu geaddet.
Nach jedem Durchlauf würde ich gerne den Eintrag an der Stelle j in meine TextArea schreiben, damit ich von System.out.println wegkomme.

Jetzt bekome ich allerdings folgenden Fehler in Zeile 63 (2. for-Schleife):
Code:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

Hier mal mein Quellcode von actionPerformed.

Java:
        if (e.getSource()==jBerzeugen) {
            String textEingabe = tAein.getText();
            String suchString = jTFsuche.getText();
            String textAusgabe = "";
            String newShit = "";
            String link = "";
            /*int bisZahl = textEingabe.indexOf(suchString)+suchString.length();
            int aWhile = start;
            int eWhile = end;*/
            int ending = end-start;

            for(int i = start;i<end;i++) {
                newShit = i+"";
                textAusgabe = textEingabe.replace(suchString,newShit);
                System.out.println(textAusgabe +"\n");
                links.add(textAusgabe);
                for(int j = 0;j<ending;j++) {
                    link = links.get(j);
                }
                tAaus.setText(link + "\n");
            }

        }

Hoffe, mir kann jemand helfen .. vielleicht gibt es ja eine Möglichkeit, das Array komplett auszugeben und nach jedem Eintrag einen Zeilenumbruch zu machen, das würde mir schon reichen 😉
 
Zuletzt bearbeitet:
du greifst auf das zweite element eines arrays mit größe 1 zu... schau dir an, in welcher zeile die exception fliegt, du hast dich wahrscheinlcih mit dem index vertan

lg
 
Wie meinst du das mit im "im index vertan" ?
Was muss ich denn ändern ?
Ich verstehe zwar die Kernaussage deines Posts, aber wenn ich j = -1 setze gehts auch nicht.
 
welchen wert haben end und start?
gib doch einfach j aus bevor du damit auf die liste greifst...


Index: 1, Size: 1... wir fangen bei 0 an, index 1 ist das zweite du hast aber nur eins...
 
hilfreich wäre zu wissen wie sich "end" und "start" berechnen. weil damit scheinst du einen falschen wert in "ending" zu erhalten, der um 1 größer ist als du willst
 
Index fängt bei 0 an. D.h. wenn nur ein Eintrag existiert, hat er den index 0, du versuchst aber auf index 1 zuzugreifen.
Warum? k.a., musst mehr Code zeigen. Oder einfach mal Debugausgaben reinsetzen und selber überprüfen.
 
K, hier ist der komplette Code 😉

Java:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.ArrayList;
public class Count extends JFrame implements ActionListener
{
    private JTextField jTFsuche;
    private TextArea tAein,tAaus;
    private JButton jBerzeugen;
    private ArrayList <String> links = new ArrayList <String>();
    int start,end;
    public Count(int anfang, int ende)
    {
        super ("LINK-GEN by Jats v1.0");
        setSize(700,700);
        setLocation(30,50);
        setResizable(true);
        setLayout(null);

        jTFsuche = new JTextField();
        jTFsuche.setBounds(20,320,300,30);
        add(jTFsuche);

        tAein = new TextArea();
        tAein.setBounds(20,20,500,250);
        add(tAein);

        tAaus = new TextArea();
        tAaus.setBounds(20,400,500,250);
        add(tAaus);

        jBerzeugen = new JButton("Links erzeugen");
        jBerzeugen.setBounds(550,380,120,30);
        jBerzeugen.addActionListener(this);
        add(jBerzeugen);

        start=anfang;
        end=ende;

        setVisible(true);

    }

    public void actionPerformed(ActionEvent e) {    

        if (e.getSource()==jBerzeugen) {
            String textEingabe = tAein.getText();
            String suchString = jTFsuche.getText();
            String textAusgabe = "";
            String newShit = "";
            String link = "";
            int ending = end-start;

            for(int i = start;i<end;i++) {
                newShit = i+"";
                textAusgabe = textEingabe.replace(suchString,newShit);
                System.out.println(textAusgabe +"\n");
                links.add(textAusgabe);
                for(int j = -1;j<ending;j++) {
                link = links.get(j);
                }
                tAaus.setText(link + "\n");
            }

        }

    }
}
 
Starte BlueJ und erstell ein neues Objekt Count und geb die Parameter ein.

EDIT:
Entschuldigung, hab das falsch verstanden.
Momentan die Zahlen 5771 für anfang und 5831 für ende.
 
Zuletzt bearbeitet:
wie kommen die einträge in die arrayList "links" ?

wenn du "5771 für anfang und 5831 für ende" nutzt .. dann hast du da 60 einträge die du abfragen möchtest, dein j in der 2. schleife läuft also von 0 - 59

edit: ah gefunden:
du füllst im ersten durchlauf die liste mit dem ersten element, in der j-schleife willst du dann aber gleich von element 0 - 59 alles abfragen, da hauts dich raus .. in dem fall kannst du getrost auf
Code:
j < links.size()
zurückgreifen und j wieder 0 starten lassen
 
Zuletzt bearbeitet:
Okay, jetzt hab ichs verstanden 😉
Aber jetzt sagt BlueJ mir "size has private acess in java.util.ArrayList" obwohl ich die ArrayList extra schon public gemacht habe.
 
Hmm .. unser Lehrer hatte uns zwar gesagt, man rufe size ohne runde Klammern auf, aber mit geht es.
Bin mit folgendem Code aber immernoch outOfBounds:

Java:
       for(int i = start;i<end;i++) {
                newShit = i+"";
                textAusgabe = textEingabe.replace(suchString,newShit);
                System.out.println(textAusgabe +"\n");
                links.add(textAusgabe);
                for(int j = 0;j<links.size();j++) {
                    link = links.get(j);
                }
                tAaus.setText(link + "\n");
            
}
 
Zuletzt bearbeitet:
naja post doch nochmal den stacktrace und einfach den kompletten code

edit:

for(int j = 0;j<links.size();j++) {
link = links.get(j);
}

das sollte keine IOOBE werfen aber ist trotzdem ziehmlicher quatsch. kannste dir die for-schleife sparen und sowas machen:
Java:
link = links.size() > 0 ? links.get(links.size()-1) : null;

aber glaub auch nicht wirklich, dass das gewünscht ist
 
Zuletzt bearbeitet:
Hmm .. ich weiß leider immernoch nicht, warum das nicht funktioniert.
Ich habe die Start- und Endwerte von den Schleifen auch schon verändert, aber immer OutOfBounds :/

EDIT: K, here u go..

Java:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.ArrayList;
public class Count extends JFrame implements ActionListener
{
    private JTextField jTFsuche;
    private TextArea tAein,tAaus;
    private JButton jBerzeugen;
    public ArrayList <String> links = new ArrayList <String>();
    int start,end;
    public Count(int anfang, int ende)
    {
        super ("LINK-GEN by Jats v1.0");
        setSize(700,700);
        setLocation(30,50);
        setResizable(true);
        setLayout(null);

        jTFsuche = new JTextField();
        jTFsuche.setBounds(20,320,300,30);
        add(jTFsuche);

        tAein = new TextArea();
        tAein.setBounds(20,20,500,250);
        add(tAein);

        tAaus = new TextArea();
        tAaus.setBounds(20,400,500,250);
        add(tAaus);

        jBerzeugen = new JButton("Links erzeugen");
        jBerzeugen.setBounds(550,380,120,30);
        jBerzeugen.addActionListener(this);
        add(jBerzeugen);

        start=anfang;
        end=ende;

        setVisible(true);

    }

    public void actionPerformed(ActionEvent e) {    

        if (e.getSource()==jBerzeugen) {
            String textEingabe = tAein.getText();
            String suchString = jTFsuche.getText();
            String textAusgabe = "";
            String newShit = "";
            String link = "";
            int ending = end-start;

            for(int i = start;i<end;i++) {
                newShit = i+"";
                textAusgabe = textEingabe.replace(suchString,newShit);
                System.out.println(textAusgabe +"\n");
                links.add(textAusgabe);
                for(int j = 0;j<links.size();j++) {
                    link = links.get(j);
                }
                tAaus.setText(link + "\n");
            }

        }

    }
}

Code:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at count.actionPerformed(count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at count.actionPerformed(count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at Count.actionPerformed(Count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at Count.actionPerformed(Count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at Count.actionPerformed(Count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at Count.actionPerformed(Count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at Count.actionPerformed(Count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(ArrayList.java:324)
	at Count.actionPerformed(Count.java:64)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
 
Zuletzt bearbeitet:
nrg ich vermute das was du da geschrieben hast, ist gar nicht die absicht des programms 🙂 .. aber das klärt sich wenn die schleifen erstma durchlaufen

poste bitte nochmal den kompletten code, dann probier ich hier mal rum
 
du sollst nicht auf gut glück irgendwas ändern, sondern verstehen was da passiert. aber dein lehrer gibt anscheinend sein sprachverständnis 1zu1 weiter, weil nach der aussage hat er imho 0 davon. nicht böse nehmen 🙂.

der zugriff auf eine arraylist oder auf ein array erfolgt über den index. dieser index darf einfach nie < 0 sein und auch nie >= der länge. wenn du das beachtest, kriegst du auch keine ioobe's mehr
 
naja post doch nochmal den stacktrace und einfach den kompletten code

edit:



das sollte keine IOOBE werfen

Tut es aber leider.

kannste dir die for-schleife sparen und sowas machen:
Java:
link = links.size() > 0 ? links.get(links.size()-1) : null;

aber glaub auch nicht wirklich, dass das gewünscht ist

Hauptsache, ich bekomme keine Fehler mehr 😉
Aber warum sollte das nicht erwünscht sein ?

Ähm .. das ist der komplette Code 😉

EDIT:
Ach fuck, Doppelpost.
Sorry, war keine Absicht !
Also was braucht ihr noch an Info ? ^^
 
Zuletzt bearbeitet von einem Moderator:
kennste teamviewer? wenn ja, schreib mir id und pw als pn. wenn nicht, schnapp dir ein tut, deinstalliere bluej und fang an in notepad++ zu entwickeln 🙂

edit: weil so können wir das spielchen noch 3 seiten lang spielen
 
Java:
//im konstruktor noch das einfuegen
setDefaultCloseOperation(EXIT_ON_CLOSE);
Java:
for(int j = 0;j<links.size();j++) {
     tAaus.append(links.get(j) + "\n\r");
}
 
Stimmt, hab mich schon gewundert, warum das Programm sich nie hat schließen lassen oO
Okay, das werde ich mal ausprobieren, falls nrg's TeamViewer-Hilfe nicht funktioniert, aber ich bin zuversichtlich 😀
 
also ich brauchte NICHTS ändern, gab keine exception!
hab nur die ausgabe mal in der art geändert das sie sinn macht, glaube das ist auch das was du vorhast 🙂
 
nach dem teamviewer kann ich ehrlich gesagt auch nicht sagen, woran das jetzt lag 🙂. bei mir ging das auch ohne probleme, mal abgesehn davon, dass der code bissle wirr ist. denke das war halt noch von einen der vorherigen laufzeiten.. scheiss bluej 😉
 

Zurück
Oben