View Single Post
Old 02-02-2013, 01:44 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Looks to me that you have jumped into the deep end of the pool before trying out the shallow end. There's a lot here you are wanting to do, but you're not familiar with the basics before continuing into the intermediate functionality.
Start simple, then move to complex. The idea you have is right, but its implementation is incorrect. You have datatype mismatches here, and incorrect usage of object properties.

Here's what I suggest. Start without worrying about a visual rendering component. Drop all associations with gui components, and work it off of a command line app. The goal is to get the data from the file, and into an array or collection. Choose if the array should be primitive like a double[][], or an array of object such as Point. I'd suggest using a multidimensional primitive since that will kill two birds with one stone. Once you have the data in the array, then iterate it using a for or foreach style for syntax and just a tabular style output. When you have this data, then you can move into gui components.
Watch for your datatypes and property handling. myPoints isn't a datatype, so it cannot be instantiated, and points isn't defined as any datatype. Watch your scope as well, nested loops cannot use the same control variable (ie: i), since i will be altered in both the inner and outer loops. Use different variables for control (i, j are typically good options). I'd suggest using split on a simple space character, and then using trim on the strings provided.
When you can get the data into the array properly, then you can look at the gui aspect. I'd extend a JPanel directly and accept the data collection into the constructor OR give it a file to read itself.
If you don't follow the simple to complex approach when learning a language, you'll always end up in the situation of "its not working but I don't know what is wrong". This is why you need to get a solid understanding of each part one at a time in order to diagnose what is wrong. That way you can look at something and say "the file is correctly read and stored, but its not rendered on the panel properly" so that gives you a spot to debug instead of being unsure of what in particular isn't working.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote