开发者

Java UI equivalent of Scanner [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

We know that Scann开发者_JS百科er is one of the many ways used for interaction purpose,through java console. Is there any UI equivalent of Scanner other than Swing?


What do you want to do? Scanner is a utility for making inputs from streams and files easy.

For GUI, you need a GUI element, and the ones java provides are based on swing. You can use JOptionsPane.showInputDialog for getting basic input and use Scanner over this string (Scanner can operate on Files, Streams and Strings. See the constructors of Scanner.

If you don't want Swing, you can use JFace InputDialog, or build your own dialog.

Update
Looks like you are porting a console application to a web application, and need an alternative for console inputs.

This depends on console input. If what you are getting from the console is configuration parameters, you can use a properties file or xml file. If what you get is dynamic user input, you have to create a JSP. You probably have a server and a servlet. If not you have write them too.

Try looking for some servlet and JSP tutorials on how to get started.


StreamTokenizer is a bit dated, but it's arguably faster. Even without Swing, you still have the TextComponent classes. The append() method of TextArea seems like a good choice.


If you want a GUI, then you can use Eclipse's SWT to create a custom dialog box for input.

For displaying messages and retrieving simple input (OK, Cancel, etc.) use org.eclipse.swt.widgets.MessageBox. Here you'll find code snippets.

If you need to retrieve input as a text value, build your own dialog. You can find a custom input box here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜