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

    Default Register content of jTextField

    Hi

    Is there a way of registering what is written in a jTextfield and then displaying a message on jLabel. I tried the following

    created a boolean
    Java Code:
    boolean bool1 = false;
    added a method check();
    Java Code:
    if(jTextField.getText()="1"&&
    jTextField1.getText()="1"&&
    jTextField2.getText()="1")
    return bool1 = true
    if(bool1=true)
    {
    jLabel.setText("Victory");
    }
    finally when there's a mouseclick event registed in every field do method check();

    Any ideas would be appreciated

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    It's hard to understand what you mean by "registering"? Are you trying to check JTextField contents on JButton click? If so, then get the content's in the button's action listener. If my advice doesn't help you, you may wish to post an SSCCE to better illustrate your problem.

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

    Default

    Ok to put it short

    There are no buttons, just textfields. If 3 textfields contain a String = "X" there is a simple String displayed on a jLabel "WON"

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    If you want to follow changes to JTextFields without use of a JButton (and I recommend that you use a button by the way), you can always listen for document changes by using a DocumentListener on the three JTextField's documents. The tutorials will explain how to do this.

Similar Threads

  1. Adding jTextField() content to the database?
    By Stephen Douglas in forum New To Java
    Replies: 12
    Last Post: 04-08-2010, 09:50 AM
  2. Oracle connection and register
    By digioleg in forum New To Java
    Replies: 1
    Last Post: 08-19-2009, 07:43 PM
  3. Replies: 1
    Last Post: 01-30-2009, 06:44 PM
  4. can't register a MySQL driver
    By prfalco in forum New To Java
    Replies: 4
    Last Post: 02-03-2008, 11:13 PM
  5. Clean the content of the JTextField
    By elizabeth in forum AWT / Swing
    Replies: 1
    Last Post: 07-26-2007, 08:38 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
  •