• Post Reply Bookmark Topic Watch Topic
  • New Topic

cmd line input VS gui input  RSS feed

 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey

I am new to GUI programming in general. Sorry if it sounds too stupid...

Is it ok to say that Command line input uses Scanner class while GUI input uses GUI component getText, getPassword etc methods? I mean I cannot use Scanner class to get GUI input correct?

Thanks
 
Liutauras Vilda
Sheriff
Posts: 4916
334
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, a warm welcome to CodeRanch, nice to see you around

Mohammad Ashari Rahman wrote:I am new to GUI programming in general. Sorry if it sounds too stupid...
This forum is unique, there are no stupid or silly questions, all questions are good and welcome, especially when folks can answer to them and help to each other.
We are all here for the same reasons - learn and enjoy the time spent over here. Some of well experienced guys mostly of the time spend here by teaching rather than learning, but even though, they learning to teach

And I think you're right about what you have doubt ;)
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a great oversimplification but many people use a Scanner for keyboard input, yes.
You often write text on text components,yes and access it with the getText method (etc, etc). You can actually pass such text to a Scanner and use it to analyse the text.That text has the advantage over Integer.parseInt that it is much less likely to produce Exceptions.
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Mohammad! It's true. Many "help sites" flame you if you ask "stupid" questions or offend one of their many minor rules. We're of the opinion that what's really stupid is to assault people just because they don't yet understand. It's not like anyone was ever born already knowing this stuff, after all!

Aside from that, we're also very big on helping people understand "why", not just "how". If you know "why", the "how" often makes more sense.

So here's a little "why" for you...

There are more than one GUI and command line frameworks in the Java world. In fact, there are at least 3 desktop GUI frameworks (AWT, Swing and SWT), plus quite a few web GUI frameworks (Struts, JSF, Wicket, Cocoon, and many more). Not all of them return data in the same way. Some of them, in fact, you have to call something to get data whereas others (such as JSF) deliver the data straight to you.

Similarly, on a command line, you can use a scanner. But, depending on your needs and the complexity of the commands, you might also parse input manually, use regexes or use a third-party library such as one of the ones available from the Apache foundation.

A lot of desktop apps support a dual-mode operation where either GUI or command-line input is possible. This is especially true for Unix/Linux, where a lot of the GUI apps started out as command-line apps that were later augmented. And for apps where you would want to be able to run them unattended, as from a timer-dispatched script file.

So there's no One Solution. Whatever works best for the job at hand will do.
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all ...best site !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!