Results 1 to 1 of 1
Thread: Help with display arrays
- 02-13-2012, 10:26 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 48
- Rep Power
- 0
Help with display arrays
Hi there.
I need help display an array one line at a time using JLabel. I get this weird text in place of the array when I run the program:
[LInventoryDefine;@1a918d5
What am I doing wrong? How do I solve this so it displays the array one line at a time?
Here is my code:
Java Code:import javax.swing.JFrame; public class GUIRun { public static void main(String[] args) { InventoryAdvanced inventory = new InventoryAdvanced(); inventory.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); inventory.setSize(300,300); inventory.setVisible(true); //Define the calculation variables double c1; double c2; double c3; //Declare the calculation variables c1 = 13.00; c2 = 5.00; c3 = 10.00; //Declare the 5% restocking fee double fee = .05; double cost; cost = 130.00; //Create the objects InventoryDefine swordstone = new InventoryDefine("Sword In The Stone Movie", 1, 10, 13.00, 130.00); InventoryDefine hercules = new InventoryDefine("Hercules Movie", 2, 20, 5.00, 100.00); InventoryDefine mermaid = new InventoryDefine("The Little Mermaid Movie", 3, 30, 10.00, 300.00); InventorySort sortThis = new InventorySort(); InventoryCal cal = new InventoryCal(); SwordStone movie = new SwordStone(); //Use an object to store the array InventoryDefine[] inventoryArray = new InventoryDefine[3]; //Declare the arrays inventoryArray[0] = swordstone; inventoryArray[1] = hercules; inventoryArray[2] = mermaid; inventory.showArray(inventoryArray); /*//Call the method from the sortThis object sortThis.Sort(inventoryArray); //Call the method from InventoryCal cal.calVar(c1, c2, c3); //Override the method from InventoryInherit movie.calVar(cost, fee); */ } }Java Code:/* Author: Ben Hartnett Sources: Java: A Beginner's Guide Source 2: Monster example posted on student forums Date Retrieved: 1-26-2012 */ import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingConstants; public class InventoryAdvanced extends JFrame { //Create the GUI private JLabel label1; //Add JLabels to JFrame public InventoryAdvanced() { super( "JLabel" ); setLayout( new FlowLayout() ); } public void showArray(InventoryDefine[] array) { label1 = new JLabel("" + array); add( label1 ); } }
Similar Threads
-
Display only certain contents of text file and edit display
By blkshrk81 in forum New To JavaReplies: 1Last Post: 12-01-2010, 06:35 PM -
What is the different between Text format display on web browser and display on midle
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-31-2010, 08:46 AM -
Arrays.sort... why sorting all arrays in class?
By innspiron in forum New To JavaReplies: 6Last Post: 03-23-2010, 01:40 AM -
How to display a list of items and on click display subitems?
By mandyj in forum New To JavaReplies: 8Last Post: 12-29-2008, 07:12 AM -
How to display information about the display device in SWT
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks