d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > How Do You Merge System.in With Graphics?
Add Reply New Topic New Poll
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
May 18 2013 01:31am
I'm trying to make a really basic blackjack game using drawingpanel and graphics, but when i try to utilize Scanner (System.in) , it seems like i have to use the alternate output window. How can I use system.in inside the graphics panel?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 18 2013 01:44am
Why are you trying to use system.in if you have a gui? if you want user input, they should be clicking a button or other gui control
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
May 18 2013 01:58am
i just want to display text inserted by the user...so not necessarily system.in, i just need whatever code needed to display user input
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
May 18 2013 01:58am
Simplest way is JOptionPane ( http://docs.oracle.com/javase/6/docs/api/javax/swing/JOptionPane.html )

For exemple
Code
String inputValue = JOptionPane.showInputDialog("Please input a value");
will get input from user

This post was edited by m0hawk on May 18 2013 01:59am
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
May 18 2013 01:59am
Quote (m0hawk @ May 18 2013 07:58am)


thank you
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 18 2013 02:15am
if you're trying to display info, i think you want system.out, not system.in. but yes, using gui controls is preferable. if it's just for logging purposes then you should be using a log file
Member
Posts: 5,988
Joined: May 6 2006
Gold: 30.00
May 18 2013 03:55am
Quote (carteblanche @ May 18 2013 08:15am)
if you're trying to display info, i think you want system.out, not system.in. but yes, using gui controls is preferable. if it's just for logging purposes then you should be using a log file


no i wanted input from a user to be able to be displayed as output. Similar to system.in --> system.out, but wiht the gui interface. i just wanted a direct code to make that happen

the purpose of it is for a blackjack game where a user can type something (like their name) where it can then be converted into text on the graphics interface
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
May 18 2013 03:32pm
why don't you have user enter string in JTextfield and use the getText() method to extract the string
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll