Hi there I'm having trouble with a java project, I need to display four arrays under privateVoidDisplayAllPurchases() which related to the Display All button in the GUI; private double  cost , private String nameOfPurchase , private double weight and private double  costPerKg in the DisplayText area
I tried DisplayTextArea.setText("\t" + nameOfPurchase); to display one array, but It doesn't work
Could anyone give some help/tips?
would be appreciated
Don't try doing anything on a GUI until you can do it without. You should have some method of displaying those arrays from the command line. Better still, a method which returns a String (or similar) representing the output.
Are you really running parallel arrays? Good grief, that is really error‑prone. You should have a Purchase class, and that class should encapsulate cost weight, etc. Also it should have the usual methods, particularly toString, which enables you to display it on screen. Then you will get sensible output from the following two lines:-
System.out.println(purchases[i]); And once you have got that working from the command line/terminal, you will find it easier to show that on your GUI.
Thankyou cambell, I have done a similar project which just outputs information through the Command Line Interface, which is easier
Yeah I am required to do four parallel arrays!
I can manage to output the array data into the CLI by using
I'll now try to move on to the GUI,still working on it, but cant seem to get it working :/
thanks for your time
The fact that you can beat parallel arrays into submission doesn't mean they are good code. What a shame that you have been told to use them rather than a proper Purchase class.
And don't even think of a GUI until you have your code working at the command line. You won't get a GUI to work if the underlying model doesn't work. Working means you can call a method and print its output. Like this:-
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop