Link to home
Start Free TrialLog in
Avatar of tjgquicken
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.IllegalArgumentException: Invalid remove
   at javax.swing.JTextArea.replaceRange(Unknown Source)
   at com.sun.deploy.util.ConsoleWindow$25.run(Unknown Source)
   at java.awt.event.InvocationEvent.dispatch(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilter(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)
Avatar of ebertk
ebertk

This execption is thrown when you attempt to replace an invalid section of the JTextArea with the method replaceRange.  Do you call this method, if so, could you post some code.  

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.
Avatar of tjgquicken

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
Avatar of ebertk
ebertk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you know how I can deal with it gracefully? It sort of interrupts my application.