This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Newbie help w/2-D Array and GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Newbie help w/2-D Array and GUI" Watch "Newbie help w/2-D Array and GUI" New topic
Author

Newbie help w/2-D Array and GUI

Bruce Laker
Greenhorn

Joined: Nov 16, 2012
Posts: 2
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

Joined: Oct 02, 2003
Posts: 10042
    
    6

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.


Never ascribe to malice that which can be adequately explained by stupidity.
Phil English
Ranch Hand

Joined: Jun 18, 2012
Posts: 62

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

Joined: Mar 12, 2011
Posts: 808

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

Joined: Nov 16, 2012
Posts: 2
I figured it out. Disregard my question.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Well done solving it. How did you do it?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Newbie help w/2-D Array and GUI
 
Similar Threads
If-Else help please
Trouble with Exception Handling
Array Comparison doesnt appear to be working
Exception Handling of tokens
Exception Handling