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.

Page 2 of 2 FirstFirst 12
Results 26 to 35 of 35

Thread: how to put changeable value in JTextField?

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: how to put changeable value in JTextField?

    Is the textfield whose setText() method you are calling, visible in the GUI?
    Print out the values of aa and aa.textField where the call to setText() is.
    If you don't understand my answer, don't ignore it, ask a question.

  2. #27
    Member
    Join Date
    May 2012
    Posts
    34
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default Re: how to put changeable value in JTextField?

    aa: Zaidimas.baaaa@b162d5
    aa.textField: javax.swing.JTextField[,21,114,65x20,invalid,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@1cfb549,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=0,columnWidth=0,command=,horizontalAlignment=LEADING]

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: how to put changeable value in JTextField?

    Is the textfield whose setText() method you are calling, visible in the GUI?

    aa.textField: javax.swing.JTextField[,21,114,65x20,invalid,
    Last edited by Norm; May 19th, 2012 at 12:41 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #29
    Member
    Join Date
    May 2012
    Posts
    34
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default Re: how to put changeable value in JTextField?

    how it can be invisible if it is declared:
    public JTextField textField;

    and it is set:
    textField.setVisible(true);

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: how to put changeable value in JTextField?

    I do not think You can have a non window component visible by itself without its containing window being visible.

    How many instances of the window/frame class that contains the textfield does the code create? Are all of them visible?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #31
    Member
    Join Date
    May 2012
    Posts
    34
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default Re: how to put changeable value in JTextField?

    I do not think You can have a non window component visible by itself without its containing window being visible.
    what do you mean?
    i can see that textbox, when i run my project.
    and as i said, if I use setText() method in the same (baaaa) class, i can see the value of the textbox.

    How many instances of the window/frame class that contains the textfield does the code create? Are all of them visible?
    one instance of a frame class is in a ball class where i'm trying to set that textfield value (after ball hits a block). thats all.

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: how to put changeable value in JTextField?

    How many instances of the frame with the textfield do you create? Are they all visible?
    If you don't understand my answer, don't ignore it, ask a question.

  8. #33
    Member
    Join Date
    May 2012
    Posts
    34
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default Re: how to put changeable value in JTextField?

    i don't get it... sorry, my english skills are poor, specially about programming things

  9. #34
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: how to put changeable value in JTextField?

    Add a println next to the statement that creates the textfield. If it prints more than once you have two text fields, one visible and one hidden. If you change the contents of the hidden one you will not see any changes in the visible one.

    Otherwise you will have to create a small, simple program that compiles, executes and shows the problem. I don't know what the code is doing without seeing it and and having a version I can test.
    If you don't understand my answer, don't ignore it, ask a question.

  10. The Following User Says Thank You to Norm For This Useful Post:

    scorpas (May 21st, 2012)

  11. #35
    Member
    Join Date
    May 2012
    Posts
    34
    Thanks
    17
    Thanked 1 Time in 1 Post

    Default Re: how to put changeable value in JTextField?

    actually, i rewrote my JFrame class.
    delete those instance of JFrame class in other classes.
    when i call setText() method by just writing:
    class_name.textField.setText(Integer.toString(app. score));
    and it works!

    Forum was offline, im allready finished my project.
    Tomorow i will try to get some grade from my teacher

    thanks Norm, for trying.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Need help int JTextField
    By n00b in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 1st, 2011, 09:57 AM
  2. how to delete a JTextField?
    By A4Andy in forum AWT / Java Swing
    Replies: 10
    Last Post: August 31st, 2011, 11:33 AM
  3. JTextField ActionListener
    By macko in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 30th, 2011, 01:53 AM
  4. drawString and JTextField
    By that_guy in forum AWT / Java Swing
    Replies: 9
    Last Post: January 29th, 2011, 02:43 AM
  5. Jtextfield Validation
    By nimishalex in forum AWT / Java Swing
    Replies: 8
    Last Post: December 11th, 2010, 02:42 AM

Tags for this Thread