DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2006

    NetBeans Form Builder and using paintComponent method()?

    Hello everyone. I'm a little new to NetBeans so forgive me if this is an easy question but for the life of me I can't seem to figure this out. Anyways, I'm trying to use the form builder in Netbeans and I want to include a JPanel and override the paintComponent method do so some drawing. So, If I include the Standard JPanel I'm not inheriting from it and can't override the paintComponent method. However, if I try and create a JavaBean class that inherits from JPanel and overrides the paintComponent method and add it to the palette... it is invisible when I go to add it to the form.

    This is really stumping me as to how I can override the method and yet still use the Form Builder...

    Any ideas? I also noticed you could add a AWT Canvas class but I'm confused. Why would you add a Canvas if you don't have the paint method()? Am I missing something obvious or what because it seems like too simple a task to be having such a big problem.

    Thanks for your help in advance!

  2. #2
    Join Date
    Oct 2005
    Never used a form builder for Java. I've tried some plugins for eclipse, but I thought it was easier to do Swing by hand. Just make a class like...
    public class MyCanvas extends JPanel{
    void paintComponent(Graphics g){
    Then add it to your frame by hand. What do you need the form builder for?

  3. #3
    Join Date
    Jun 2004
    I doubt hit has to do with Netbeans itself. Check out the following for help.


  4. #4
    Join Date
    Nov 2004
    One quick & dirty solution could be to just use the form builder using a plain JPanel first, then when the formbuilding is done you just step into the code and replace the JPanel with your JPanel extension.

    Yes, I suspect that NetBeans will get trouble if you return to the formbuilding after the panel replacement, its a dirty solution, almost a hack...
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.