Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Stuck at Writing in Txtbox

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Stuck at Writing in Txtbox

    Hello people,

    i'm making virtual keyboard and i stucked at smth silly but dunno how to solve it

    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
    Last edited by blad3cro; October 31st, 2012 at 05:03 PM.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default 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(...).

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Stuck at Writing in Txtbox

    Quote Originally Posted by blad3cro View Post
    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.

  5. #5
    Junior Member
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Stuck at Writing in Txtbox

    thank you man...i apprecaite your help a lot i will try

  6. #6
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Stuck at Writing in Txtbox

    Good. I have confidence that you will succeed if you do!

Similar Threads

  1. Please Help I'm stuck
    By mael331 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 6th, 2011, 10:02 AM
  2. Help! im stuck!
    By aznguy92 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 15th, 2011, 10:16 PM
  3. Im stuck, please help
    By bigsmoke101 in forum Loops & Control Statements
    Replies: 3
    Last Post: April 12th, 2011, 05:34 PM
  4. Stuck again
    By Tate in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 28th, 2010, 11:22 AM
  5. I'm stuck
    By iank in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 5th, 2009, 10:21 AM