Article View: borland.public.jbuilder.java.swing
Article #12273Re: JTextField scrolls off screen
From: Matt Krevs
Date: Wed, 27 Jan 1999 00:00
Date: Wed, 27 Jan 1999 00:00
51 lines
2505 bytes
2505 bytes
Are you saying that you call setText() in the constructor of your subclass?
If so maybe ( and this is a BIG maybe ) the JTextField hasnt been setup as a
DocumentListener to itself properly at the time you call setText(). What
happens if you call setText() after the subclass has been created.
eg call setText() after you have instantiated the subclass of JTextField.
Alex B. Humphreys wrote in message <36A8F818.31C32759@sema4.com>...
>Thanks, but neither the validate nor the changing of alignment nor any
>combination thereof helped.
>
>Interestingly, I notice the problem only appears when I subclass JTextField
>and assign the setText there (I'm setting a default for my NumJTextField of
>0.00).
>
>Any other possibilities?
>
>Matt Krevs wrote:
>
>> Just an idea
>>
>> What happens if you call validate() for the container of the JTextField
>> after calling setText(). You shouldnt have to do this but I wonder what
>> effect it would have.
>>
>> Another thing to try would be to change the alignment to LEFT, call
>> setText() and then reset the alignment to RIGHT.
>>
>> Alex B. Humphreys wrote in message <36A5F60D.CB3112E3@sema4.com>...
>> >I have a class called NumJTextField that extends JTextField. The code
>> >follows:
>> >
>> >public NumJTextField() {
>> > setMargin(new Insets(2, 2, 2, 2));
>> > setHorizontalAlignment(JTextField.RIGHT);
>> >}
>> >
>> >Problem is, when I setText on the textfield in my code, it appears
>> >hidden behind the left side of the field. I can manually scroll the
>> >field over and see my code, but this is of course unacceptable. Any
>> >ideas why the field doesn't setText in a clean manner? If it's
>> >important, I have the textFields expanding as needed using a
>> >GridBagLayout and I reassign the value of the textFields many times
>> >(repainting doesn't seem to help after each assignment).
>> >
>> >Thanks.
>> >
>> >Alex
>> >
>
Technical Details
Message-ID:
<78lfjn$ii4@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36A5F60D.CB3112E3@sema4.com> <785nt9$ek917@forums.borland.com> <36A8F818.31C32759@sema4.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,21cc40309718ce26 X-Google-Attributes: gid111d45,public From: "Matt Krevs" <mattkrevs@flex.com.au> Subject: Re: JTextField scrolls off screen Date: 1999/01/27 Message-ID: <78lfjn$ii4@forums.borland.com> X-Deja-AN: 437284753 References: <36A5F60D.CB3112E3@sema4.com> <785nt9$ek917@forums.borland.com> <36A8F818.31C32759@sema4.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing