Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-19-2007, 08:20 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
GUI Help
I'm making a Sudoku game. Now, i've got the logic working, where it tests to see if the numbers right. But here's my problem, the program consists of an ArrayList of 81 JTextFields, few of which are already set and unable to be edited (like the numbers given to you in a Sudoku puzzle). So my problem is that, i need to make an integer array of the actual numbers. So basically what's happening is that, the ArrayList is empty and I'm getting a NullPointerException.

Here is what i've been trying to do in order to convert. (Assume that i've done everything necessary to place the textfields in their place, and i've set some of the text of the textfields for the given numbers. Keep in mind, all of the following code is placed in the actionPerformed method for an inner class which implements ActionListener , and is used for when a JMenuItem is clicked).


--------------------------------------------------
ArrayList<JTextField> numbers = new ArrayList<JTextField>();
int[] actualNumbers = new int[81];
for(int x = 0; x < actualNumbers.length; x++)
{
actualNumbers[x] = Integer.parseInt(numbers.get(x).getText());
}
--------------------------------------------------------
now, this compiles with no problem, but I get a NullPointerException after i fill in the textFields with random numbers when i click the JMenuItem. So its a problem with it reading the numbers from the textfields. which is where i need help.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 10:20 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org