Article View: borland.public.jbuilder.java.swing
Article #347Re: overridden JTextField in JDialog
From: Hiroshi
Date: Sun, 28 Aug 2005 22:02
Date: Sun, 28 Aug 2005 22:02
33 lines
2352 bytes
2352 bytes
Thank you so much, yes, it worked!
When I was experimenting this paint() in JDialog, I saw the
text field (with blank, although some text was preset to the
control) momentarily shown before it is overridden. So I
thought that after the paint() of the dialog, super.paint()
is causing the overriding...so I wondered how I can stop
super to paint itself...
Anyway thanks again.
Doychin Bondzhev <doychin@dsoft-bg.com> wrote:
>try to call super.paint() before your paint code.
>
>Doychin
>
>Hiroshi wrote:
>> Hi everyone, a JTextField in a JDialog (or its extended class)ends up with mostly-overridden by paint() for the dialog. Below is the code to demonstrate the problem. When paint() is not included in the dialog class, the field is normally shown, but with it, the field is almost lost. Will you tell me why and how I can avoid this problem? (I do need to include paint() in the dialog class.) Thank you.
>>
>> PS paint() is called right after add() and not called after show().
>>
>> import java.awt.*; import javax.swing.*;
>> class testDlg {
>> static JDlgExt dlg=new JDlgExt();
>> public static void main (String args[]) {
>> dlg.getContentPane().setLayout(new FlowLayout());
>> dlg.setBounds(10,10,200,200);
>> dlg.getContentPane().add(new JTextField("text field",12));
>> dlg.show();
>> } }
>> class JDlgExt extends JDialog
>> {public void paint(Graphics g) {System.out.println("paint!");}}
Technical Details
Message-ID:
<43123480$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<43112344$1@newsgroups.borland.com> <431168c2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,bf940752da9e232e X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Hiroshi" <hiroshinakata@hotmail.com> Sender: "Hiroshi" <hiroshinakata@hotmail.com> Reply-To: "Hiroshi" <hiroshinakata@hotmail.com> Subject: Re: overridden JTextField in JDialog Newsgroups: borland.public.jbuilder.java.swing X-User-Info: 69.192.157.16 References: <43112344$1@newsgroups.borland.com> <431168c2@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <43123480$1@newsgroups.borland.com> Date: 28 Aug 2005 15:02:40 -0700 X-Trace: newsgroups.borland.com 1125266560 207.105.83.66 (28 Aug 2005 15:02:40 -0700) Lines: 34 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail