Re: How to combine characters



Okay, I'm still not getting it.
Does anyone know how to combine char's from a KeyEvent to combine into
a string?
Thank you....

My current code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

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();
final StringBuffer strb = new StringBuffer (s);

if(!s.equals(" "))
{
System.out.println (strb.toString());
strb.append (s);
}
ke.consume();
}
});

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



Relevant Pages

  • Re: Need to return multiple values.
    ... like they have StringBuffer. ... HashMap abc; ... This beats an array IMO because ur not dealing with indices which you ... > public void p ...
    (comp.lang.java.programmer)
  • Re: Need to return multiple values.
    ... like they have StringBuffer. ... HashMap abc; ... This beats an array IMO because ur not dealing with indices which you ... > public void p ...
    (comp.lang.java.help)
  • Re: String vs String Buffer
    ... public void f{ ... StringBuffer buffer = new StringBuffer; ... > The one place where it is fine to use String concatenation and people so ...
    (comp.lang.java.help)
  • Re: Can you detect if a class is mutable ?
    ... Robert Klemme wrote: ... public void foo(const StringBuffer sb) { ... (And, yes, I know that some effort will be necessary on the API and the JVM to achieve this, but it's not too difficult.) ...
    (comp.lang.java.programmer)
  • Re: Pet shop store
    ... I think immutable strings are a good thing. ... but the idea seems okay. ... StringBuffer becomes StringBuilder) ... model take place on the GUI thread. ...
    (comp.object)