Re: Missing Graphics in JComponent or JPanel
From: ThomasH (henrymot_at_any.net)
Date: 11/30/04
- Next message: Alex: "How to pass an array of objects from C++ to Java using JNI"
- Previous message: IchBin: "Re: Problems making a Graph"
- In reply to: A. Bolmarcich: "Re: Missing Graphics in JComponent or JPanel"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Nov 2004 17:23:12 -0800
"A. Bolmarcich" wrote:
>
> On 2004-11-29, ThomasH <henrymot@any.net> wrote:
> > Hi,
> >
> > I face a strange problem, which bugged me already back than with
> > AWT, Swing seems to have the same issue:
> >
[...]
>
> What you are doing wrong is trying to get information about a native
> screen resource associated with a component before the component's
> peer has been created. You should override the addNotify() method
> of your extension of JPanel with something like
>
> public void addNotify() {
> super.addNotify();
> FontMetrics fm = getFontMetrics(getFont());
> // calculate the size using the FontMetrics
> }
>
> Geary explains it with the FontSelectionPanel example in "Graphic
> Java 1.1 Mastering the AWT".
Excellent, thanks. I called addNotify(), but its not the same
like super.addNotify() called in the overwritten function!
Thanks again!
Thomas
- Next message: Alex: "How to pass an array of objects from C++ to Java using JNI"
- Previous message: IchBin: "Re: Problems making a Graph"
- In reply to: A. Bolmarcich: "Re: Missing Graphics in JComponent or JPanel"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]