Results 1 to 5 of 5
Thread: Problem with my return method
- 10-18-2010, 07:18 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
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.
my getter from Customer class...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; }
and finally from my SubFrame class...Java Code:public String getName() { return name; }
What am I missing, please help me.Java Code:MainFrame m = new MainFrame(); listItems = new JList(m.getCustomer());
- 10-18-2010, 07:31 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
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...
- 10-18-2010, 07:54 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
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?
-
- 10-19-2010, 06:34 AM #5
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
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
-
how to return a value from runnable method
By udinulis in forum AWT / SwingReplies: 10Last Post: 07-20-2010, 05:06 AM -
Not able to return the method value
By dmakshay2002 in forum Advanced JavaReplies: 11Last Post: 05-28-2010, 02:07 PM -
Method won't return value
By footyvino in forum New To JavaReplies: 2Last Post: 03-26-2010, 10:49 AM -
Method return type problem
By McChill in forum New To JavaReplies: 7Last Post: 05-05-2009, 09:21 PM -
Return value of method
By cachi in forum New To JavaReplies: 1Last Post: 08-01-2007, 08:23 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks