是否可以打印用户可以编辑的文本(对于控制台程序)? [英] Is it possible to print text that can be edited by the user (for console programs)?

查看:46
本文介绍了是否可以打印用户可以编辑的文本(对于控制台程序)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我允许用户编辑某些内容,例如通讯簿中的电话号码(实际上,这正是我在做的事情).是否可以添加到println中,以便允许我插入变量以显示为完全可编辑的文本?我正在为此分配的作业实际上并不需要,但是我认为拥有它是很酷的.我正在Google上搜索,但找不到任何东西,那么我又真的不知道我在寻找什么以及我是否记有正确的用语...

Say I allow the user to edit something, like the phone number in an Address Book (actually, that's exactly what I'm doing). Is there something that I can add to println that will allow me to insert a variable to display as fully editable text? The assignment that I'm doing this for doesn't actually call for this, but I think it would be cool to have. I'm looking on Google but can't find anything, then again I don't really know what I'm looking for and whether or not I have the correct terms in mind ...

推荐答案

否,不仅仅使用Java在框架中提供的内容.编辑某些文本需要

No, not using only what Java provides in the framework. Editing some text would require to

  1. 按键操作,这是不可能的,因为在Java中,输入被缓冲(即,等待Enter键被按下)
  2. 在输出的文本中四处移动,这也是不可能的

这可以通过使用某些本机代码(在Linux上为ncurse,...),使用JNI或JNA来完成,但这并不容易.

This could be done using some native code (ncurse on linux, ...), using JNI or JNA, but not that easily.

请注意,有些项目旨在添加这些功能,因此,如果您可以使用核心库之外的内容,则可以尝试一下...例如 http://code.google.com/p/java-console-api/

Note that there are some projects that aim to add those functionalities, so if you can use something outside of the core libraries, you could give them a tries... for instance http://code.google.com/p/java-console-api/

这篇关于是否可以打印用户可以编辑的文本(对于控制台程序)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆