Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4949
| From | Novice <novice@example..com> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Strange JTable issue in Sun's Java code |
| Date | 2012-01-17 01:48 +0000 |
| Organization | Your Company |
| Message-ID | <Xns9FDCD472333ABjpnasty@94.75.214.39> (permalink) |
| References | <Xns9FDC8ADEB9988jpnasty@94.75.214.39> <jf1ufa$kt$1@dont-email.me> |
Jeff Higgins <jeff@invalid.invalid> wrote in news:jf1ufa$kt$1@dont-
email.me:
> 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.
>
> I don't see any line numbers in the code you have provided.
> 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 this<code>SizeSequence</code>.
>> * Note that the values of<code>start</code> and
>> *<code>length</code> must satisfy the following
>> * conditions:<code>(0<= start< getSizes().length)
>> * AND (length>= 0)</code>. 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);
>> }
>> ========================================================================
>
Sorry for the delay!
I've just stepped through the whole removeEntries() method until it
crashed. I should mention that I downloaded a Java 1.7 JDK and JRE and I'm
using _that_ version now. The code for this method looks the same but I
might be missing a subtle difference. Here's the code, along with what I
saw as I stepped through it:
public void removeEntries(int start, int length) {
//Before executing the following line, start and length both show "cannot
//be resolved to a variable". When I tried setting them as expressions in
//the expressions monitor, I got "<error(s)_during_the_evaluation>" for
//both variables
int sizes[] = getSizes();
//getSizes() returns an int array of 45 items; each item has a value of
//21
//when I inspect or inspect 'sizes' (without the brackets), I get "sizes
//cannot be resolved to a variable. It's not clear if the assignment has
//worked!
//Before this next line, 'start' and 'length' are still "cannot be
//resolved to a variable."
int end = start + length;
//After the assignment, 'end' "cannot be resolved to a variable"
//Before this next line, 'a' is an int array of 45 diverse integers and
//'a.length is 45. 'length' "cannot be resolved to a variable"
int n = a.length - length;
//After the preceding statement is executed, 'n' "cannot be resolved to a
//variable"
a = new int[n];
//After the preceding statement is executed, 'a' has a value of "[]" (!!)
for (int i = 0; i < start; i++) {
//Before the following line is executed the first time, 'i' should be zero
//but Eclipse says "i cannot be resolved to a variable". 'sizes[i] cannot
//be resolved to a variable".
a[i] = sizes[i] ;
//Upon executing the preceding line the first time through the loop, we get
//the ArrayIndexOutOfBoundsException for an index value of 0
}
for (int i = start; i < n; i++) {
a[i] = sizes[i+length] ;
}
setSizes(a);
}
This seems REALLY messed up to me. I don't understand why all these
variables "cannot be resolved to a variable". If they really don't have
values, why doesn't it crash long before we get to the line where we get
the exception? But if the variables do have values, why can't Eclipse show
them to me?
Since a newer JDK/JRE didn't resolve the problem and it happens
consistently, I'm leaning toward Eclipse as being the problem here. I can't
think of anything inappropriate that I'm doing in my code and I have to
believe that the Java team tests these methods pretty thoroughly before
putting them in a JDK.
Am I thinking along the right lines here? If so, what do I do next? I'd
like my program to work without getting this apparently inappropriate
exception but I'm not sure how to accomplish that....
--
Novice
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Strange JTable issue in Sun's Java code Novice <novice@example..com> - 2012-01-16 18:34 +0000
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-16 14:48 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-16 14:55 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-16 15:19 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-16 15:31 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-16 17:57 -0500
Re: Strange JTable issue in Sun's Java code Novice <novice@example..com> - 2012-01-17 01:48 +0000
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-17 03:22 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-17 03:29 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-17 03:49 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-17 03:55 -0500
Re: Strange JTable issue in Sun's Java code Novice <novice@example..com> - 2012-01-17 22:21 +0000
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-17 18:18 -0500
Re: Strange JTable issue in Sun's Java code Jeff Higgins <jeff@invalid.invalid> - 2012-01-17 20:56 -0500
Re: Strange JTable issue in Sun's Java code Novice <novice@example..com> - 2012-01-18 05:24 +0000
Re: Strange JTable issue in Sun's Java code Novice <novice@example..com> - 2012-01-18 17:40 +0000
Re: Strange JTable issue in Sun's Java code Novice <novice@example..com> - 2012-01-18 05:37 +0000
Re: Strange JTable issue in Sun's Java code Christian Kaufhold <chka@ucuri.chka.de> - 2012-01-19 21:00 +0100
csiph-web