Results 1 to 5 of 5
  1. #1
    jeata is offline Member
    Join Date
    Oct 2010
    Posts
    33
    Rep Power
    0

    Default jTextLabel and jTextField

    Hi

    I guess this looks pretty pathetic, but I can't figure out how to take a String, save and then display its content in a TextLabel as many times as I like, by pressing a button. For example, if you write "Dog" in the textfield, press a button attached to a textlabel, you get the "Dog" displayed, after that if you write "Cat" in the txt field it just displays "Cat". How can I make it display DogCat and so on, as many times the user presses the button it just needs to keep adding those strings to the textLabel

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,928
    Rep Power
    8

    Default

    Not sure what a JTextLabel is, but you have a method to get the current text of the component, right? And a method to set the text? And you know how to concatenate Strings?

  3. #3
    jeata is offline Member
    Join Date
    Oct 2010
    Posts
    33
    Rep Power
    0

    Default

    concat right, thanks alot man, but when i concat them they are just displayed together, like f.e. when I input Dog, it just outputs DogDog and when I press the button again it does the same:)
    Last edited by jeata; 10-29-2010 at 08:30 PM.

  4. #4
    SQUALL is offline Member
    Join Date
    Oct 2010
    Posts
    9
    Rep Power
    0

    Default

    try this ::in the button click :

    label.setText (label.getText()+" "+field.getText());

    of course

    label (JTextLabel) & field (textfield)

    I hope that help you ...

  5. #5
    jeata is offline Member
    Join Date
    Oct 2010
    Posts
    33
    Rep Power
    0

Similar Threads

  1. Focusing on the next JTextField
    By britto_bicsjohn in forum AWT / Swing
    Replies: 2
    Last Post: 08-26-2009, 03:53 PM
  2. JTextField
    By gancio in forum AWT / Swing
    Replies: 20
    Last Post: 08-26-2009, 03:11 PM
  3. Replies: 1
    Last Post: 01-30-2009, 06:44 PM
  4. JtextField
    By kashifu in forum Advanced Java
    Replies: 2
    Last Post: 06-27-2008, 04:25 PM
  5. help with JTextfield
    By gary in forum New To Java
    Replies: 4
    Last Post: 07-11-2007, 01:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •