Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27992 > unrolled thread

Newbie question about updating a disabled JTextField

Started byangel.gutierrez.rodriguez@gmail.com
First post2014-04-09 03:43 -0700
Last post2014-04-09 11:42 -0700
Articles 5 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Newbie question about updating a disabled JTextField angel.gutierrez.rodriguez@gmail.com - 2014-04-09 03:43 -0700
    Re: Newbie question about updating a disabled JTextField Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-09 07:52 -0400
    Re: Newbie question about updating a disabled JTextField FredK <fred.l.kleinschmidt@gmail.com> - 2014-04-09 07:10 -0700
      Re: Newbie question about updating a disabled JTextField angel.gutierrez.rodriguez@gmail.com - 2014-04-09 09:10 -0700
    Re: Newbie question about updating a disabled JTextField Roedy Green <see_website@mindprod.com.invalid> - 2014-04-09 11:42 -0700

#27992 — Newbie question about updating a disabled JTextField

Fromangel.gutierrez.rodriguez@gmail.com
Date2014-04-09 03:43 -0700
SubjectNewbie question about updating a disabled JTextField
Message-ID<fe011e0f-cd77-4f34-afff-d51e7e57f9b8@googlegroups.com>
Is it possible to change the text of a JTextField when it is disabled?

I do have 2 JTextFields (a & b) and sometimes, the second one is disbaled and then it has the same value as the first, so I tried:

b.setText(a.getText());

when the first one is changed. But it looks it isn't working. Do I have to enable it first?

Thanks in advance,

AGR

[toc] | [next] | [standalone]


#27994

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-04-09 07:52 -0400
Message-ID<li3ca5$79q$1@dont-email.me>
In reply to#27992
On 4/9/2014 6:43 AM, angel.gutierrez.rodriguez@gmail.com wrote:
> Is it possible to change the text of a JTextField when it is disabled?
>
> I do have 2 JTextFields (a & b) and sometimes, the second one is disbaled and then it has the same value as the first, so I tried:
>
> b.setText(a.getText());
>
> when the first one is changed. But it looks it isn't working. Do I have to enable it first?

     setText() works on enabled or on disabled fields, so the problem is
most likely somewhere else in your code.

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#27996

FromFredK <fred.l.kleinschmidt@gmail.com>
Date2014-04-09 07:10 -0700
Message-ID<765ca279-7011-4be8-b1d6-44e326f7e843@googlegroups.com>
In reply to#27992
On Wednesday, April 9, 2014 5:22:57 AM UTC-7, Stefan Ram wrote:
> angel.gutierrez.rodriguez@gmail.com writes: >I do have 2 JTextFields (a & b) and sometimes, >the second one is disbaled and then it has >the same value as the first, so I tried: >b.setText(a.getText()); If the second has the same value as the first, setting it to the same value again should have no effect. Maybe you meant »it has /to have /the same value as the first«?

Be sure you do this on the AWTEventThread, or else the change may not show up correctly.
-- 
Fred K

[toc] | [prev] | [next] | [standalone]


#27999

Fromangel.gutierrez.rodriguez@gmail.com
Date2014-04-09 09:10 -0700
Message-ID<3480a37c-e258-4a4e-b3b0-7e6feeddc13a@googlegroups.com>
In reply to#27996
Thank you all, guys.

At the end, it was a problem of my code (as Eric said). Knowing that it could be done and checking what FredK said, made me focus in the rest of the code.

You were right too, Stefan.

My mistake(s)...

[toc] | [prev] | [next] | [standalone]


#28002

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-04-09 11:42 -0700
Message-ID<125bk9luu6ljfn42iv6bb7r22ci9lgd0op@4ax.com>
In reply to#27992
On Wed, 9 Apr 2014 03:43:40 -0700 (PDT),
angel.gutierrez.rodriguez@gmail.com wrote, quoted or indirectly quoted
someone who said :

>Is it possible to change the text of a JTextField when it is disabled?

That is something you can easily find out by experiment.  The worst
that can happen is an exception.
 
Yes. Disabling just refers to how the component appears on screen and
behaves to the user. The component itself works normally when it is
disabled.

-- 
Roedy Green Canadian Mind Products http://mindprod.com
"Don't worry about people stealing an idea; if it's original, you'll
 have to shove it down their throats." 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web