Results 1 to 2 of 2
  1. #1
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    London, UK
    Blog Entries
    Rep Power

    Question Trouble adding JPanel to JFrame with NetBeans IDE

    Hi, I've designed some JFrame forms in netbeans which I intended to add to the main JFrame. Then I realised thats not possible so I created a new JPanel form and then copy+pasted the contents and source code of the minor JFrame form to the JPanel form.

    Now I need to add the JPanel form to the main JFrame but whatever I've tried won't get the JPanel to display... Please tell me what I am doing wrong?

    I tried this way:
    //productsPanel is a JPanel in the main JFrame
    productsPanel.add(new ProductsViewer());

    I also tried this:
    ProductsViewer myProductsViewer = new ProductsViewer();

    And I also tried to use these two methods after adding the JPanel to the JFrame:

    Nothing seems to get this JPanel to show.

    Please help!!


  2. #2
    JavaForums's Avatar
    JavaForums is offline Administrator
    Join Date
    Dec 2006
    Rep Power


    You seem to do it in reverse. You need to add JPanel to JFrame like this:

    Java Code:

Similar Threads

  1. Adding JButton to JPanel
    By razmyasdfg in forum AWT / Swing
    Replies: 8
    Last Post: 05-23-2011, 11:03 PM
  2. Adding a jpanel to a customized Jpanel Class
    By trishtren in forum AWT / Swing
    Replies: 7
    Last Post: 04-05-2011, 06:52 PM
  3. Adding Jpanel ontop of another Jpanel
    By Manfizy in forum AWT / Swing
    Replies: 4
    Last Post: 03-05-2011, 10:34 PM
  4. adding integer to the JPanel
    By navid in forum New To Java
    Replies: 2
    Last Post: 12-18-2010, 04:26 PM
  5. I am having trouble with scrollbars in netbeans 5.5.1
    By ineedhelp in forum New To Java
    Replies: 2
    Last Post: 03-13-2009, 06:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts