Hello, I've been trying recently to find out how to print out text into the screen like from keyboard, that is printing into active window, just like from keyboard port. Is there a premade package/method for that or how do I use the keyboard port?

You could make a window by using JFrame from javax.swing.

JFrame window = new JFrame("This is my windows title")

You could use a JTextField so the user can input into the text field.

JTextField UserInput = new JTextField("Text to go inside the textfield, optional")

and you could have a string to get the text of the JTextField.

String s = UserInput.getText()

Hello, I've been trying recently to find out how to print out text into the screen like from keyboard, that is printing into active window, just like from keyboard port. Is there a premade package/method for that or how do I use the keyboard port?

what do you mean my print... you mean type? if so what he said^^^ bext time explain better

That really depends on where you are taking the keyboard input from.

If you're looking to take it from the console, you can use the Scanner class

Scanner input = new Scanner(System.in);
System.out.print("Input something: ");
String line = input.nextLine();

However, if you want to know each key that entered as its entered, you need to invoke a KeyListener. If you just need the complete input, you can do something similar to what mango posted previously.

That really depends on where you are taking the keyboard input from.

If you're looking to take it from the console, you can use the Scanner class

Scanner input = new Scanner(System.in);
System.out.print("Input something: ");
String line = input.nextLine();

However, if you want to know each key that entered as its entered, you need to invoke a KeyListener. If you just need the complete input, you can do something similar to what mango posted previously.

This article has been dead for over six months. Start a new discussion instead.