Re: Drawing with Extended JPanel Class

philju <[email protected]> Thu, 7 Aug 2008 10:35:08 -0700 (PDT)
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>
Hi Wade,

All the classes impacted by this issue reside in the same project and
package.

I've sent you the small (< 100KB) zipped project to your email address with
additional information.

Many thanks for your help!

Cheers,
Phil


Wade Chandler wrote:
> 
> Is this UI project a separate project from where (another project
> possible) you are trying to use it? Do you have the UI project compiled or
> at least that class? If it is another project you are trying to use this
> one from, do you have the UI project setup as a dependency for that other
> project?
> 
> Also, if it is a small enough project, zipped under 20 megs, and you want
> me to help you directly, you can zip it up and send it to
> [email protected] directly, and when I get a few minutes I see
> what the issue is.
> 
> Hope something there helps,
> 
> Wade
> 
>  ==================
> Wade Chandler, CCE
> Software Engineer and Developer, Certified Forensic Computer Examiner,
> NetBeans Dream Team Member, and NetBeans Board Member
> http://www.certified-computer-examiner.com
> http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
> http://www.netbeans.org
> 
> 
> 
> ----- Original Message ----
>> From: philju <[email protected]>
>> To: [email protected]
>> Sent: Thursday, August 7, 2008 9:47:30 AM
>> Subject: Re: [nbui] Drawing with Extended JPanel Class
>> 
>> 
>> Hi Wade,
>> 
>> Thanks for the response, I will remember where to post next time ;-)
>> 
>> Thanks for your advice, I have now moved the extended JPanel class back
>> into
>> the ui project package, but this has now meant that the class doesn't
>> appear
>> when I search for beans to add to the palette within the project folder
>> and
>> the automatically created distribution JAR. But I am also unable to drag
>> &
>> drop the class from the project manager onto the JFrame from the visual
>> design view.
>> 
>> My extended JPanel class doesn't have any dependencies on any other JARs
>> or
>> libraries, only other JDK classes and one from the project. To test this
>> I
>> reduced the class to a very minimal extension as below and am still
>> experiencing the same problem.
>> 
>> Cheers,
>> Phil
>> 
>> ------------------------------------------------------------------------------------------
>> 
>> package ui;
>> 
>> import java.awt.Graphics;
>> import java.io.Serializable;
>> import javax.swing.JPanel;
>> 
>> public class LegendPanel extends JPanel implements Serializable {
>>     
>>     private String title;
>>     private String colour;
>>     private int min;
>>     private int max;
>>     
>>     public LegendPanel() {
>>         
>>     }
>>     
>>     public void paint(Graphics g) {
>>         
>>         super.paintComponent(g);
>>     }
>>     
>>     public String getTitle() {
>>         return this.title;
>>     }
>> 
>>     public void setTitle(String title) {
>>         this.title = title;
>>     }
>> 
>>     public String getColour() {
>>         return this.colour;
>>     }
>> 
>>     public void setColour(String colour) {
>>         this.colour = colour;
>>     }
>> 
>>     public int getMin() {
>>         return this.min;
>>     }
>> 
>>     public void setMin(int min) {
>>         this.min = min;
>>     }
>> 
>>     public int getMax() {
>>         return this.max;
>>     }
>> 
>>     public void setMax(int max) {
>>         this.max = max;
>>     }
>> }
>> 
>> 
>> 
>> Wade Chandler wrote:
>> > 
>> > ----- Original Message ----
>> > 
>> >> From: philju 
>> >> To: [email protected]
>> >> Sent: Tuesday, August 5, 2008 6:09:41 AM
>> >> Subject: Re: [nbui] Drawing with Extended JPanel Class
>> >> 
>> >> 
>> >> Hi Wade, 
>> >> 
>> >> Sorry for the mis-posting, I'm new to this forum! Thanks for replying
>> >> anyway...
>> >> 
>> >> I thought adding the bean to the palette might be essential, in which
>> >> case I
>> >> have an additional problem... 
>> >> 
>> >> Below is the code for my extended JPanel, and currently it resides in
>> the
>> >> root - "default package" of the project source folder. I believe I've
>> met
>> >> all of the JavaBeans requirements and as such NetBeans registers the
>> >> class
>> >> as a valid bean when attempting add it from the project folder using
>> the
>> >> palette manager. I select the bean and the palette category, no
>> message
>> >> is
>> >> generated which leads me to believe the process has been successful.
>> >> However, when I access the palette it isn't visible, even following a
>> >> refresh. 
>> >> 
>> >> Dragging the class from the project navigator onto the form for visual
>> >> development doesn't result in anything happening either. Any thoughts? 
>> >> 
>> > 
>> > Does this class have any dependencies in any other JARs or libraries
>> other
>> > than Swing? Also, it is now recommended, after Java 1.4, to always use
>> a
>> > package as it can cause different issues with different class loaders.
>> > Your problem might resolve itself if you don't have any dependencies
>> and
>> > move your class into a package. Also, make sure you build the class
>> before
>> > you try to drag it from the project window.
>> > 
>> >> Can I also ask if including a second, non empty constructor would
>> violate
>> >> the JavaBeans coding convention? 
>> > 
>> > It will not. The JavaBeans specification itself doesn't actually
>> enforce
>> > the default constructor in text I don't believe, however, with any
>> > specification is a reference API, and there are classes in that API
>> > (java.beans) which require default constructors to work with JavaBeans,
>> > and all other code does this as well, because it is the only easy way
>> for
>> > instantiation without some type of bean factory standard or something
>> > along those lines. Regardless, as long as the usage of your class by
>> the
>> > IDE or other JavaBean tools is not dependent upon this other
>> constructor
>> > it is perfectly fine. I do this all the time, and then I can change the
>> > initialization code in NB to use my other constructor.
>> > 
>> >>Please let me know if you would prefer I
>> >> re-post this in nbusers. 
>> >> 
>> > 
>> > It's fine to finish up here, just please remember in the future. Thanks
>> > for the understanding here.
>> > 
>> > 
>> > Wade
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Drawing-with-Extended-JPanel-Class-tp18814353p18870889.html
>> Sent from the Netbeans - UI mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Drawing-with-Extended-JPanel-Class-tp18814353p18875760.html
Sent from the Netbeans - UI mailing list archive at Nabble.com.