Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Can you put a scanner in the drawing panel or would that have to be done prior to opening the drawing panel?

+2 votes
asked Feb 5, 2015 in (Winter 14) by Haley Jones (100 points)

1 Answer

+2 votes
You can't put a Scanner in the drawing panel... and you can't use a Scanner to get keyboard input from a drawing panel.  Your two choices are:

a) use a Scanner to get input from System.in, which means people will need to type their input into the console in Eclipse.  It would probably be best to do this before opening/creating the DrawingPanel, since after the window is popped up, your users are unlikely to know that they need to go back to the console to type something.

b) You can get one keystroke at a time, using keyboard input methods (see the interactive graphics example posted to Moodle).  This works well for dealing with individual keys being pressed (like choosing a,b,c,d for multiple choice, or checking to see which arrow key they pressed for controlling a game), but not very well for collecting whole words.

Hope that helps...
answered Feb 8, 2015 by Forrest Stonedahl (3,308 points)
...