Results 1 to 2 of 2
  1. #1
    maverik_vz is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default HELP with jPanels

    Using netbeans I've created new JFrame object with JPanel inside. Now I want to add new Jpanel object and add it to a previous JPanel.
    Something like this:

    Java Code:
    package p;
    public class mainFrame extends javax.swing.JFrame {
         public mainFrame() {
             super("New Frame");
             JPanel panel1 = new JPanel();
             panel2 p2=new panel2();
    public class panel2 extends javax.swing.JPanel {
         public panel2() {
            jLabel2 = new javax.swing.JLabel();
            jLabel1 = new javax.swing.JLabel();
    public class Main  {
        public static void main(String[] args) {
               mainFrame M = new mainFrame();
    Of course, the new panel2 won't show in the mainFrame...please help...

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    The problem is with your use of layout manager. You should read the Sun Swing tutorial on this subject which you can find here: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI with JFC/Swing)

Similar Threads

  1. JList and JPanels
    By JetsYanks in forum New To Java
    Replies: 8
    Last Post: 12-25-2009, 03:11 PM
  2. Help with overlapping JPanels
    By xcallmejudasx in forum New To Java
    Replies: 2
    Last Post: 03-09-2009, 11:19 PM
  3. Managing jPanels in jSplitPane
    By calexander in forum Advanced Java
    Replies: 6
    Last Post: 11-13-2008, 08:06 PM
  4. Problems with JPanels and displaying
    By Mastergeek666 in forum AWT / Swing
    Replies: 1
    Last Post: 01-19-2008, 01:32 AM
  5. How to add Images to JPanels?
    By Soda in forum New To Java
    Replies: 3
    Last Post: 12-08-2007, 06:54 PM

Posting Permissions

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