This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Making a Scanner (java.util.Scanner) in a jframe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Making a Scanner (java.util.Scanner) in a jframe?" Watch "Making a Scanner (java.util.Scanner) in a jframe?" New topic
Author

Making a Scanner (java.util.Scanner) in a jframe?

johann cruz
Greenhorn

Joined: Oct 06, 2013
Posts: 4
is there a way to somehow place a scanner in a text, ex:
type a value for a
[text box aka Scanner]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38057
    
  22
Yes, but why?
You can pass the text from a text box to the Scanner.
Have you read about text components? There are about three kinds. If you want an input, you usually use a text field, because that is smaller and takes a single line. You can get an int out of a text field like this:-…but there are easier ways to do it.

Please explain what you are trying to do, then we can think how to do it later.
johann cruz
Greenhorn

Joined: Oct 06, 2013
Posts: 4
i wan't to make a calculator, actually i have a ready one that works in the console, but i wan't one text feild to be the first number, another to be the second, and in between them will be the operator (+, _, *, /, %)
johann cruz
Greenhorn

Joined: Oct 06, 2013
Posts: 4
btw im using switch for the operators, heres the code without Jframe

Bernhard Goetz
Ranch Hand

Joined: Jan 07, 2013
Posts: 35

Hi johann,

What kind of use case do you have?

You can try to emulate the console with the combination of a JTextField - which works like the console input (Enter erases the text and "feeds" the calculator) - and a JTextPane above it - which works as the input log.
Having two textboxes for the operands and a let's say JComboBox in between for the operator seems a bit unhandy for a calculator in my opinion.

Best regards,
Bernhard Goetz
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making a Scanner (java.util.Scanner) in a jframe?
 
Similar Threads
How to Read from Console and File in a program!
Scan a text file.
How to transfer data from paper to db
Get pathname to data file
how do i input