tjgquicken
asked on
Please help me understand this Java exception
I have a Java applet that basically downloads a file and draws a progress bar across the screen showing how much of the file is downloaded. I'm getting the following exception, but I don't understand where it's coming from. Can anybody help me? Thanks.
Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentE xception: Invalid remove
at javax.swing.JTextArea.repl aceRange(U nknown Source)
at com.sun.deploy.util.Consol eWindow$25 .run(Unkno wn Source)
at java.awt.event.InvocationE vent.dispa tch(Unknow n Source)
at java.awt.EventQueue.dispat chEvent(Un known Source)
at java.awt.EventDispatchThre ad.pumpOne EventForFi lter(Unkno wn Source)
at java.awt.EventDispatchThre ad.pumpEve ntsForFilt er(Unknown Source)
at java.awt.EventDispatchThre ad.pumpEve ntsForHier archy(Unkn own Source)
at java.awt.EventDispatchThre ad.pumpEve nts(Unknow n Source)
at java.awt.EventDispatchThre ad.pumpEve nts(Unknow n Source)
at java.awt.EventDispatchThre ad.run(Unk nown Source)
Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentE
at javax.swing.JTextArea.repl
at com.sun.deploy.util.Consol
at java.awt.event.InvocationE
at java.awt.EventQueue.dispat
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
ASKER
Here's the problem: I don't have a JTextArea (or anything that extends JTextArea) anywhere in my applet. Could the JTextArea that the exception is referring to be the Java console?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Do you know how I can deal with it gracefully? It sort of interrupts my application.
IllegalArgumentException - if part of the range is an invalid position in the model
replaceRange(String str, int start, int end)
Make sure the start and end are valid for the text currently in the JTextArea. As a first test, I would simply eliminate the use of the replaceRange and set the entire piece of text in the JTextArea. If the exception goes away, then it is just a matter of checking the start and end of the JTextArea contents before you call this method (to make sure they are valid) Or - catch the exception and a handle gracefully.