Re: Newbie again. "Java Keyboard input" is a failure as a google search. What isn't?
ram@zedat.fu-berlin.de (Stefan Ram) writes:
Swing should already be set up to accept any common
Unicode-character from the keyboard and display any common
Unicode-character in the GUI, well at least every character
from ISO-8859-1.
public class Main implements java.lang.Runnable, java.awt.event.ActionListener
{ static final javax.swing.JFrame frame = new javax.swing.JFrame();
static final javax.swing.JTextField input = new javax.swing.JTextField();
public void run()
{ input.addActionListener( this );
frame.add( input ); frame.pack(); frame.setVisible(true); }
public void actionPerformed( final java.awt.event.ActionEvent event )
{ javax.swing.JOptionPane.showMessageDialog( frame, input.getText() );
System.exit( 0 ); }
public static void main( final String[] args )
{ javax.swing.SwingUtilities.invokeLater( new Main() ); }}
1. Text can be entered (edited) and terminated with the return key.
2. Text will be displayed in a message box.
3. User presses [OK].
4. Program terminates.