This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie help w/2-D Array and GUI

 
Bruce Laker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im using Netbeans to create a program/project for school that takes user input from two text fields, stores it in an array. I have created the GUI and Array but get errors when defining the on-enter event.

Here is the array definition:

And here is the textfield retrieval:

Looking forward to learning more. Thanks for any help.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bruce ofBruce wrote:I don't know how to post code on this forum but will try.

Here you go: How to post code.

You may want to also read our FAQ on How to Ask Questions on this site.
 
Phil English
Ranch Hand
Posts: 62
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To locate a point in a 2 dimensional space you need two coordinates. When you reference a point in your array you only use a single index this returns a slice (1D array) not a point.
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think this coding style is ill-advised. Why embed the incrementing of a variable -- a significant event by any standard -- within an array access instruction? Your intent is not entirely clear. Can you tell me the value of i when the array access occurs?

When incrementing a variable, do so in an instruction that contains nothing else but incrementing the variable, unless there is a compelling and immediately comprehensible reason to do otherwise.
 
Bruce Laker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out. Disregard my question.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done solving it. How did you do it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic