- Problem: I am unable to return values entered in an Array to a preview textbox
- Ideal solution: User presses refresh, the box is populated with the objects in the array.
- JDK: 1.8
Working Command Line Version Code:
public static void printAll(Member[] platoon){
//System.out.println("You are in the third loop");
for (int cntr=0;cntr<platoon.length;cntr++){
System.out.println("Member Name: " + platoon[cntr].getName() + " " + "Join Date: " + platoon[cntr].getJoinDate());
}
}
The above code takes a instantiated array of object type Members and returns via get methods each value stored in each Member(String Name, int day, int month, int year);.
I am attempting to do the same thing with the GUI abilities of Java. My code is somewhere around 300 lines, I am definitely willing to post it all as this is the last thing keeping me from finishing my project.
Below I write the action event that I want to use to set the text in the preview textfield with the current contents of the platoon Array. All I was attempting to do with this was place the print out from the above code into the box, it does not like the type VOID so i switched it to the return type String. Now It doesn't appear I can store the results of a For loop as a String? I am surley missing something vital.
GUI Code:
}else if(event.getSource() == refreshButton){
displayText.setText(setPreview(platoon));
}
public static String setPreview(Member[] platoon){
//System.out.println("You are in the fourth loop");
preview = (for (int cntr=0;cntr<platoon.length;cntr++){
System.out.println("Member Name: " + platoon[cntr].getName() + " " + "Join Date: " + platoon[cntr].getJoinDate()););
return preview;
}
}
Thank you all for your help, will keep this OP updated to help future Stack Overflow members with this issue.