How to combine characters



All,
Someone helped me with this code a few weeks ago, and it works
great! However I wanted to know if I could alter it. That is, the
output variable is a char. I am trying to see if I can combine the
chars being typed in until a spacebar is typed. This way instead of
outputting a char, the chars will combine into a String (hence a word)
whereby the spacebar delineates a new word being typed in....
So if I type "test" in the textfield, it wont output each char
seperately, but it will output the full word "test".
Does anyone know how to combine chars to make a word?
Thank you so much for your help...


import java.awt.*;
import java.awt.event.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.*;
import java.util.*;

public class InputObject {

public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField tf = new JTextField(30);
tf.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent ke)
{
String s = "" + ke.getKeyChar();
System.out.println(s);
//Here lookiing to combine chars to a string
ke.consume();
}
});

f.add(tf,BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
});
}
}
.



Relevant Pages

  • Re: [Emacs] Kommentieren
    ... ;; completely up to the user to decide, what the string ... "Chars preserved of STRING. ... `CHARS-PRESERVE' must be a parentized expression, ...
    (de.comp.editoren)
  • Re: FASTEST way to try all strings (a until ZZZZZZZZZZZZZZZZZZZZZZZZ)
    ... > It will be a very huge table so I in my opinion. ... > When it would be used, than it should be converted to a string, however ... >> How would an array of Byte be any faster then an array of Char? ... >> array of Byte is needed, however the OP suggested Chars (A to Z, a to z ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FASTEST way to try all strings (a until ZZZZZZZZZZZZZZZZZZZZZZZZ)
    ... > It will be a very huge table so I in my opinion. ... > When it would be used, than it should be converted to a string, however ... >> How would an array of Byte be any faster then an array of Char? ... >> array of Byte is needed, however the OP suggested Chars (A to Z, a to z ...
    (microsoft.public.dotnet.general)
  • Re:(9corr) string
    ... and I want to remove the month in the timestamp for each of the string ... Then advance 4 chars, and copy from +2 to the current pointer until you ... pointer past the year part to reach the month part. ... this guarantee is 'memmove'. ...
    (comp.lang.c)
  • Re: speed question
    ... chars of column A and first 2 of column B. ... as it is a string contatenation. ... > I want to have smart search like iTunes or something like that. ... > Dzemal Tipura (Dzemo) - MCP ...
    (microsoft.public.dotnet.framework.adonet)