简体   繁体   English

使java在键盘上键入字符串

[英]make java type out a string on keyboard

I am working on a project. 我正在做一个项目。 I want a user string (no trouble with that) to be typed out by java. 我希望通过Java键入用户字符串(没有问题)。 Is that possible and if yes, then how? 那有可能吗?如果可以,那怎么办?

Thank you! 谢谢! I don't blame for the down votes 我不怪不起票

You can't just blindly make the program type it out on the keyboard as it is not getting displayed anywhere. 您不能只是盲目地使程序在键盘上键入,因为它不会在任何地方显示。 You have to either use some third-party module that I have no idea about that presses keys for you, or you should actually store the string somewhere, some sort of text box. 您必须使用一些我不知道会为您按下按键的第三方模块,或者您实际上应该将字符串存储在某种形式的文本框中。 If you are using a java swing to make a GUI app, then simply create a JTextBox and set the text to your string like this: 如果您使用Java swing创建GUI应用,则只需创建JTextBox并将文本设置为您的字符串,如下所示:

JTextbox textbox = new JTextbox();
textbox.setText("your string goes here");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM