Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Anybody know what the heck is IllegalArgumentException..

843805Jan 23 2007 — edited Jan 23 2007
Hi,

Anybody know what exactly means by IllegalArgumentAcception? In my program the error message print out like this:
java.lang.IllegalArgumentException: bad position: 1   at javax.swing.text.JTextComponent.setCaretPosition(JTextComponent.java:1650)
From my coding:
try
     		{
                        String val = "A";
			int pos = getCaretPosition();
  			getDocument().insertString(getCaretPosition(),val,null);
			setCaretPosition(pos+1);
   			moveCaretPosition(pos+1);
			requestFocusInWindow();
     		}catch(Exception input)
     		{ input.printStackTrace(); }
It seems that the
setCaretPosition(pos+1)
in my coding facing problem. But I sure that the coding correct. Is there something out of my sight or something I incorrectly put in there. I need opinion on this matter. Can anybody help?

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 20 2007
Added on Jan 23 2007
9 comments
851 views