wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Need to convert Console App to GUI... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need to convert Console App to GUI..." Watch "Need to convert Console App to GUI..." New topic
Author

Need to convert Console App to GUI...

Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
I need some examples of how to code a GUI input form for a console based application. I am in a time crunch which is why I am askin for examples at this time. I have been attempting (without great success) to go through the sun tutorials and some other text's as well and I have also pounded my head against the monitor going through the API, but I have to get this project done NOW and haven't coded in 2 years.

I'm just looking for examples, not asking for anyone to do it for me.

Thanks.


CNSS/NSA Infosec Professional,<br />Software Engineer
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
it depends entirely on how you want to get the data from the user:
textfield
listbox
combobox
etc

and on how you want to display the output:
label
textfield
textarea
etc

the 'processing' part of your program would probably remain the same

here's a very simple demo GUI


Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
I was looking for somthing that would "explain" how to hook a button and a textbox (or boxes), so this works great.

Thanks again!
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
Ok, still lost.. I am trying to create just a search page, calling the search function in another class. I'm having problems with the button...

This is the search class:


This is my pitiful excuse for GUI code..


Needless to say... HELP is greatly appreciated...
[ May 18, 2005: Message edited by: Sam Smoot ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you would be better off starting out small

by that I mean leave the db stuff till later
(assuming it performed correctly when used via a console)

here's your GUI with a simple search class - just to check
the feel and operation of the GUI.
whether its the db class or this simple class, the result
is the same - the return value from the method S4Ids(String passedID)

Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
What?? Start Small??

I kept telling them to let me create a web application (ColdFusion) but they are too backwards to know better so I'm having to do it this way, and boy, is this a "Learning Experience".

Unfortunatetly, I have to use the data base portion.. I also have to incorporate the add part as well. They already work, and I have "stripped" them so that they can be called with passed values to update / search the database. My main problem is getting the value to the search class, etc.

I'm having problems getting the text from the srchTxt field into the argument for the search code. If I can just get that value passing correctly, I should be able to get the rest...

I've got this now..


The error I get is :

Cannot refer to a non-final variable srchTxt inside an inner class defined in a different method

Thanks for the help!
[ May 18, 2005: Message edited by: Sam Smoot ]
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
Woah! This kinda fixed it.. (Eclipse is smarter than I thought..) :roll:

Changed the value of srchTxt to final.

Changed the button code to:


and got a result... Just have to work on the layout so that it shows up...


Thanks!
[ May 18, 2005: Message edited by: Sam Smoot ]
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
It Works, but it's ugly.. Can anyone explain, help with a layout option?

I need to have the labels beside the textfields, but they are scattered. The labels acf2Lab and otisLab need to go above their respecive textfields. The line borders are not a part of the design, just somthing for me to see just what is actually going on. The blank label is supposed to be blank, but I put the + string in their to see if it was showing up, and it is, but only once...

SO CLOSE!!!


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
see if this is any closer

Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
That's much prettier than what I came up with.. I just had to increase the gridlayout by about 6 levels to get it all to "behave"....

One day I might actually know enough to be dangerous.... but for now, just clueless...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need to convert Console App to GUI...
 
Similar Threads
Colors in a console
Pattern for converting console program to GUI
Question for Jim Keogh.
Java GUI Creator
Is JavaBean for GUI?