I have a command line program that runs like the following
code:
Enter the name of the forest: The Big Forest
Enter the number of trees in 'The Big Forest': 3
Enter the 1st tree's type: Oak
Enter the number of leaves on the 'Oak': 15
Enter the name of Leaf 1: Pinky
Enter the name of Leaf 2: The Brain
...
...
Enter the 2nd tree's type: Willow
...
...
Enter the 3rd tree's type: Pine
...
...
In the programs I am making I have nested statements like this. So the command line code would be something like this.
code:
String nameTier1 = this.getInput("Enter Tier 1's name: ");
int numberTier1 = this.getInput("Enter number of elements in tier 1: ");
Tier1 t1 = new Tier1(nameTier1);
for(int i = 0; i < numberTier1; i++){
String nameTier2 = this.getInput("Enter Tier2's name: ");
String numberTier2 = this.getInput("Enter number of elements in tier 2: ");
t1.add(new Tier2(name));
for(int j = 0; j < numberTier2; j++){
String nameTier3 = this.getInput("Enter Tier3's name: ");
t2.add(new Tier3(name));
}
}
The above is a nice compact little CLI program to grab a lot of tiered input. I have a bunch of little programs that work like this, and I want to easily turn these programs into GUI programs, because nomatter how comfortable I am with the comand line my end users are not that comforable with it, and a GUI program would be much easier.
I have done these in two different ways, the first was to simulate the command line with a basic interface, with an output text area, an input text field and a submit button. I then made a sort of state machine, which when the submit button was pressed it would add the input to the textarea and then add the new output to the output window, and finally change the state, so that when submit was pressed again it would process the next block.
The other way was to create a tiered approach, where data for a level along with the number of elements in the next level would be entered and then a confirm button would be pressed, which would then fill the information into a second Panel, this second panel's information would then add input fields to a third area. This solution often leads to an ungodly amound of input. For example if the first tier had 3 input the second tier had 6 and then you needed to enter only 2 pieces of information for each of the second tier's six items you would have 21 lines of input showing up on a gui. Way to much information than should ever be placed in front of the user at one time, and that is a small example.
What I am wondering is if there is a better way to do what I have been doing? The state machine method seems a little better than the strait GUI way I was doing it before, but this method seems rather broken still (might be that I implemented it in a broken fashion).
Does anyone have experience with this? And have a better way to make this work?
Dan @ Code Town
(Edited by WarMage on 11-16-2004 19:33)