Closed Thread Icon

Topic awaiting preservation: Turning a CLI program into a GUI Program in Java (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=24071" title="Pages that link to Topic awaiting preservation: Turning a CLI program into a GUI Program in Java (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Turning a CLI program into a GUI Program in Java <span class="small">(Page 1 of 1)</span>\

 
WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 11-16-2004 19:31

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)

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 11-16-2004 20:49

Dan,

You're mixing your metaphors. The choice of a user interface should not be driven by the structure of the program. You can have either a command line interface or a graphical interface and still design the program around the state machine.

I have always liked working with state machines. I find they produce fast easy to understand code. I would recommend maintaining the state machine as the structure of the program.

I agree that customers usually are more comfortable with graphical interfaces than with command line. So why don't you try putting each tier on a different panel. This will make your tier 1 panel a little sparse, but you could fill it in with instructions, or have the ability to select from multiple tier 1 structures.

Then the panel for tier 2 would show the name (and any other relevant information) for the selected tier 1 and would allow the user to add/change any of the tier 2 information by listing all the tier 2 elements. There would then be a different panel for each tier 3 structure depending on which one the user selected at tier 2. Listing the selected structure from each of the parent tiers (like the breadcrumbs on the OzoneAsylum) would be a good thing here.

-- not necessarily stoned... just beautiful.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 11-17-2004 01:57

I should post up some screenshots tomorrow so you can see the examples.

I think mentioning a state machine confused the issue, because the use of the state machine was only to constrain the GUI and has nothing to do with the actal data.

The data structure I am using is a tree. What I am having trouble with is finding a best method to display this data, so that the user can easily create it and modify it graphically.

Dan @ Code Town

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 11-17-2004 02:00

God, I feel dumb...

I could use a JTree and have the act of selecting a node bring up the required inpu panels. I guess all you need is to think differently and the answer jumps at you.

Dan @ Code Town

« BackwardsOnwards »

Show Forum Drop Down Menu