Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.gui Subject: Re: Strange JTable issue in Sun's Java code Date: Mon, 16 Jan 2012 15:31:55 -0500 Organization: A noiseless patient Spider Lines: 68 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 16 Jan 2012 20:24:12 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="qwFw1g9RsQ6TkML5yezG9A"; logging-data="16898"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ob4tsWAhWkI2W2Nl8KRp7+loJHXEnKgM=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 In-Reply-To: Cancel-Lock: sha1:4lQd2f42Qx9SDUal8gq11/laUtc= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4946 On 01/16/2012 03:19 PM, Jeff Higgins wrote: > On 01/16/2012 02:48 PM, Jeff Higgins wrote: >> On 01/16/2012 01:34 PM, Novice wrote: >>> I'm getting an exception I don't understand when I attempt to delete all >>> the data in a small Jtable (46 rows, 3 columns). >>> >>> Here's the stacktrace; the "rowCount = 45" is a diagnostic I'm writing: >>> ======================================================================== >>> rowCount = 45 >>> Exception in thread "AWT-EventQueue-0" >>> java.lang.ArrayIndexOutOfBoundsException: 0 >>> at javax.swing.SizeSequence.removeEntries(SizeSequence.java:383) >> >>> ... When I get to line 383 of that method, I get the same "cannot be >>> resolved to a variable" notation on EVERY variable in that line, even >>> variable i, which has just been explicitly set to 0. >> > The java.lang.ArrayIndexOutOfBoundsException: 0 > would seem to indicate a null reference to the array in question. Oops! wrong again. Should be an empty array. > I cannot say which one it might be because: >> I don't see any line numbers in the code you have provided. > getSizes() might have initialized sizes to null, or a may be null. getSizes() might have returned an empty array or a might be empty. >> I don't see a variable i in the code you have provided. >>> >>> Here's the complete code for this method: >>> >>> ======================================================================== >>> /** >>> * Removes a contiguous group of entries >>> * from thisSizeSequence. >>> * Note that the values ofstart and >>> *length must satisfy the following >>> * conditions:(0<= start< getSizes().length) >>> * AND (length>= 0). If these conditions are >>> * not met, the behavior is unspecified and an exception >>> * may be thrown. >> >> Where are you checking these? >> >>> * >>> * @param start the index of the first entry to be removed >>> * @param length the number of entries to be removed >>> */ >>> public void removeEntries(int start, int length) { >>> int sizes[] = getSizes(); >> >> I would set a break point just above. >> >>> int end = start + length; >>> int n = a.length - length; >>> a = new int[n]; >> >> What is a? >> >>> for (int i = 0; i< start; i++) { >>> a[i] = sizes[i] ; >>> } >>> for (int i = start; i< n; i++) { >>> a[i] = sizes[i+length] ; >>> } >>> setSizes(a); >>> } >>> ======================================================================== >> >