Results 1 to 5 of 5
  1. #1
    braddy is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default Problem with my return method

    Hi all

    I'm doing a gui prog, but I'm doing something wrong cause it won't work. I do not get any error messages but nothing happends. Hopefully you can see what I'm missing.
    I have an arraylist which I populate with customer info and now I want to retrieve all customers by name and return from my method, but it won't work.
    I try to collect the customer names in an string array and use it to populate a jlist...

    Here are some code samples...

    from my MainFrame class where the arraylist customerList is located.
    Java Code:
     
    	public String[] getCustomer()
    	{
    		String cust[] = new String[customerList.size()];
    		int i = 0;
    
    		for (Customer c: customerList)
    		{
    			cust[i] = c.getName();
    			i++;
    		}
    
    		return cust;
    	}
    my getter from Customer class...
    Java Code:
    	public String getName()  
    	{
    		return name;
    	}
    and finally from my SubFrame class...
    Java Code:
    		MainFrame m = new MainFrame();
    		
    		listItems = new JList(m.getCustomer());
    What am I missing, please help me.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    debugging?

    customerList size 0 ?
    print the return from getCustomer() (e.g. with System.out and Arrays,toString() or use a debugger!)
    the list is visible? and so on...its hard to say with such less information...

  3. #3
    braddy is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default

    I wish I had a debugging function, but I do not. This is my school work, I have tried to manipulated with fixed values instead of size but still no luck. Can I use System.out in a gui prog?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  5. #5
    braddy is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default

    To add some more info to you, I want to collect all customers name in a string array in MainFrame and then return the array to SubFrame which is another form to populate my JList with those names. Maybe there are some other way to do it, or maybe you can see something obvious in my code that fails. If you need more of my code please say so, or if you need more info, please specify what you need. I do not want to flood this page with some hundred lines of code if not needed. I just try to explain what's wrong with my application and focus on the code right there. Thank you.

Similar Threads

  1. how to return a value from runnable method
    By udinulis in forum AWT / Swing
    Replies: 10
    Last Post: 07-20-2010, 06:06 AM
  2. Not able to return the method value
    By dmakshay2002 in forum Advanced Java
    Replies: 11
    Last Post: 05-28-2010, 03:07 PM
  3. Method won't return value
    By footyvino in forum New To Java
    Replies: 2
    Last Post: 03-26-2010, 11:49 AM
  4. Method return type problem
    By McChill in forum New To Java
    Replies: 7
    Last Post: 05-05-2009, 10:21 PM
  5. Return value of method
    By cachi in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 09:23 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •