This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to show text on console

 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am new to java GUI, I have a simple question currently I am designing Java GUI, like fill-in personal form. I am able to design and run the program but I don't know how to use system.out.printl() to show person's particular in console. Anyone could suggest me which method I should use and where should I write the method. Thanks in advance!
 
Dinesh Kumar Ramakrishnan
Ranch Hand
Posts: 68
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use System.out.println() method to display message in console as same as console programs. but it's bad idea to display message in console from gui

use JOptionPane to display your message in user interface screen
 
Paul Clapham
Sheriff
Posts: 21572
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using the javaw command to run the GUI, which is the normal thing to do, then there isn't any console for you to look at. You could switch to using java instead, in which case you'll have a shell window as well as the GUI on your screen.

But like Dinesh says, it's a bad idea to use both. If you have to use the console then that means there's some function you forgot to put into your design.

(I have in the past done debugging by using System.out.println from my GUI code, but it's far better to use a proper debugger.)
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul and Dinesh:

Thanks for the reply. I don't know what kind of method i should put in system.out.println to show the text i filled in. suppose i filled in Sara, then when i press submit button, i will be able to see sara from console, i am not sure which method i should use. Thanks!
 
shen zhang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dinesh Kumar Ramakrishnan wrote:you can use System.out.println() method to display message in console as same as console programs. but it's bad idea to display message in console from gui

use JOptionPane to display your message in user interface screen

hi Dinesh

Kindly would you tell me which method i should use to show the text i filled in the Gui. For instant, I typed Sara, then press submit button, i should be able to see Sara on the console. I know to use system.out.println() to show on console, but i don't know what should i write in the (). Thanks so much
 
Dinesh Kumar Ramakrishnan
Ranch Hand
Posts: 68
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use JOptionPane.showMessageDialog()




 
kasib kismath
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dinesh Kumar Ramakrishnan wrote:Use JOptionPane.showMessageDialog()






As Dinesh suggested we can add a JOptionPane so that if the user clicks the submit button the message is shown.
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Shen

I assume you are using text fields for those form inputs. To get the user input you can do:


Once you have that you can use JOptionPane or JDialog to display the output.

For me personally, I tend to use a status bar (JPanel really) in the bottom of the app showing the last action or whatever so that I know what button is clicked for example.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic