Stuck at Writing in Txtbox
Hello people,
i'm making virtual keyboard and i stucked at smth silly but dunno how to solve it
Code :
JButton btnC = new JButton("C");
btnC.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
text = String.format(" %s", "c");
Text_t.setText(text);
now i dont understand, when i press C, and after it i press N for example , it deletes C and writes N, what i need to add here to make it write normally.
[Sorry, i was full in this, Txtbox is referred to JTextField]
Thank you
Re: Stuck at Writing in Txtbox
I'm not sure what a "Txtbox" is as I know of no Swing component with this name. Perhaps you mean JTextField? If so, please strive to be accurate when asking questions since Java compilers and JVM's are unforgiving in this regard and so you must be as well. If this is correct, then you need to first get the text from the JTextField by calling getText(), then concatenate your new text to the end of it using the + operator, and then use this to set the text of the JTextField using setText(...).
Re: Stuck at Writing in Txtbox
Ye, it's referred to JTextBox , i'm beginner in this, last night started with that keyboard, and stuck at that, can you write me the example of the code please i would appricate it, because i dont understand all codes yet and i cant learn from books i like it this way, faster and more understanding than books
Re: Stuck at Writing in Txtbox
Quote:
Originally Posted by
blad3cro
Ye, it's referred to JTextBox , i'm beginner in this, last night started with that keyboard, and stuck at that, can you write me the example of the code please i would appricate it, because i dont understand all codes yet and i cant learn from books i like it this way, faster and more understanding than books
re: "I can't learn from books": and you never will if you don't try. Come on now, that's not how it works, and that's not how you learn. Please at least try first yourself using my recommendations. Then come back with your code if you're still stuck.
Re: Stuck at Writing in Txtbox
thank you man...i apprecaite your help a lot :D i will try :D
Re: Stuck at Writing in Txtbox
Good. I have confidence that you will succeed if you do!