paintComponent ignored ? [message #79444] |
Tue, 08 February 2005 10:17 |
Eclipse User |
|
|
|
Originally posted by: mik.c-l-a-s-s-x.it
Hello,
I've extended a JPanel and put some simple test code in the paintComponent:
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.red);
g.fillRect(0, 0, getWidth(), getHeight());
};
It looks like VE completely ignores the code in Design mode. A missing
feature ?
Mik
--
|
|
|
Re: paintComponent ignored ? [message #79513 is a reply to message #79444] |
Tue, 08 February 2005 16:28 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
It won't see such overrides in the class that is being edited because we
don't actually create an instance of the class being edited. That is
because since the class is changing it is not yet compiled and we can't
execute it.
We do execute superclasses though.
--
Thanks,
Rich Kulp
|
|
|
Re: paintComponent ignored ? [message #79527 is a reply to message #79513] |
Tue, 08 February 2005 17:26 |
Eclipse User |
|
|
|
Originally posted by: mik.c-l-a-s-s-x.it
Ok, but at least you could execute/display it when it has been correctly
compiled, at CTRL-S time.
It's an important feature, even more when creating/editing visual custom
components.
This missing feature sounds like a regression since the good old VAJ days.
Mik
--
"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> ha scritto nel messaggio
news:cuapbu$qas$1@www.eclipse.org...
> It won't see such overrides in the class that is being edited because we
> don't actually create an instance of the class being edited. That is
> because since the class is changing it is not yet compiled and we can't
> execute it.
>
> We do execute superclasses though.
>
> --
> Thanks,
> Rich Kulp
|
|
|
|
|
Re: paintComponent ignored ? [message #79931 is a reply to message #79841] |
Fri, 11 February 2005 15:33 |
Eclipse User |
|
|
|
Originally posted by: mik.c-l-a-s-s-x.it
"Joe Winchester" <winchest@uk.ibm.com> ha scritto nel messaggio
news:cufp4k$it5$1@www.eclipse.org...
> Hi Michele,
>
>> I've extended a JPanel and put some simple test code in the
>> paintComponent:
>>
>> protected void paintComponent(Graphics g)
>> {
>> super.paintComponent(g);
>> g.setColor(Color.red);
>> g.fillRect(0, 0, getWidth(), getHeight());
>> };
>>
>> It looks like VE completely ignores the code in Design mode. A missing
>> feature ?
>
> Quick question. Is this an inner class ? From your other post I assumed
> it was, but re-reading your post you don't mention whether it is or not ?
No it's not the inner-class case. Imagine you want to design your own JPanel
in VE (i.e. a JPanel with a background image).
> If it isn't an inner class and you just extended JPanel and put code
> then this won't be executed until you use the class. At design time we
> don't instantiate the bean being edited - we use the superclass instead.
Ok, that's my case.
> The reason is that the bean being edited may not be compiled, and also
> it's what you're going to be altering as you edit your Java code. While
> you edit the bean isn't necessarily compiled so what we do is instantiate
> the superclass and from analyzing the code work out what properties are
> set and what child JavaBeans there are and then create a prototype
> instance of what we think it will look like at design time. Any custom
> code (like yours) gets passed by.
Well, if you can check for the validity of the compiled class (i.e. it is
compiled without compilation errors), maybe you could use it to render a
preview at design time.
Buggy custom painting code would prevent the rendering of the preview, of
couse (imagine an infinite loop or a stack overflow). In this case you could
give a timeout to the preview rendering thread in order to check and break
the execution of bad custom code. A red X and a stacktrace could help to
find the error.
> You could extend you JPanel once more when you will see your custom code.
Yes, that's what I'm doing now, but I need to extend twice..
Cheers,
Mik
--
============================================================ ================
> ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte (PI) <
> Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB: http://www.classx.it <
============================================================ ================
|
|
|
|
Re: paintComponent ignored ? [message #605095 is a reply to message #79444] |
Tue, 08 February 2005 16:28 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
It won't see such overrides in the class that is being edited because we
don't actually create an instance of the class being edited. That is
because since the class is changing it is not yet compiled and we can't
execute it.
We do execute superclasses though.
--
Thanks,
Rich Kulp
|
|
|
|
|
|
Re: paintComponent ignored ? [message #605201 is a reply to message #79841] |
Fri, 11 February 2005 15:33 |
Michele Puccini Messages: 33 Registered: July 2009 |
Member |
|
|
"Joe Winchester" <winchest@uk.ibm.com> ha scritto nel messaggio
news:cufp4k$it5$1@www.eclipse.org...
> Hi Michele,
>
>> I've extended a JPanel and put some simple test code in the
>> paintComponent:
>>
>> protected void paintComponent(Graphics g)
>> {
>> super.paintComponent(g);
>> g.setColor(Color.red);
>> g.fillRect(0, 0, getWidth(), getHeight());
>> };
>>
>> It looks like VE completely ignores the code in Design mode. A missing
>> feature ?
>
> Quick question. Is this an inner class ? From your other post I assumed
> it was, but re-reading your post you don't mention whether it is or not ?
No it's not the inner-class case. Imagine you want to design your own JPanel
in VE (i.e. a JPanel with a background image).
> If it isn't an inner class and you just extended JPanel and put code
> then this won't be executed until you use the class. At design time we
> don't instantiate the bean being edited - we use the superclass instead.
Ok, that's my case.
> The reason is that the bean being edited may not be compiled, and also
> it's what you're going to be altering as you edit your Java code. While
> you edit the bean isn't necessarily compiled so what we do is instantiate
> the superclass and from analyzing the code work out what properties are
> set and what child JavaBeans there are and then create a prototype
> instance of what we think it will look like at design time. Any custom
> code (like yours) gets passed by.
Well, if you can check for the validity of the compiled class (i.e. it is
compiled without compilation errors), maybe you could use it to render a
preview at design time.
Buggy custom painting code would prevent the rendering of the preview, of
couse (imagine an infinite loop or a stack overflow). In this case you could
give a timeout to the preview rendering thread in order to check and break
the execution of bad custom code. A red X and a stacktrace could help to
find the error.
> You could extend you JPanel once more when you will see your custom code.
Yes, that's what I'm doing now, but I need to extend twice..
Cheers,
Mik
--
============================================================ ================
> ClassX Development Italy Via Francesca, 368/I I-56030 S.M. a Monte (PI) <
> Tel.(+39)-0587-705153 Fax.(+39)-0587-705153 WEB: http://www.classx.it <
============================================================ ================
|
|
|
|
Powered by
FUDForum. Page generated in 0.08393 seconds