title: Give JPanel customized width and height
body: <p>Why is my JPanel spreading all over the remaining part of frame when i try to resize to whatever size i want it to occupy. . . </p>
  
  <p>This is the code snippet</p>
  
  <pre><code>public class GUITabbedPane extends JFrame{
  
  TabsPanelClasses tabPanel = new TabsPanelClasses();
  public GUITabbedPane()
  {
      TabsPanelClasses.CreateAccount createAccount = tabPanel.new  CreateAccount();
      TabsPanelClasses.BorrowBook borrowBook = tabPanel.new  BorrowBook();
  
      JTabbedPane tabs = new JTabbedPane(JTabbedPane.LEFT);
  
      //Tab text support html tags
      tabs.addTab("&lt;html&gt;&lt;body marginwidth=30 marginheight=20&gt;Create Account&lt;/body&gt;&lt;/html&gt;", null,createAccount.createAccountPanel(),"New Member Account");
      tabs.addTab("&lt;html&gt;&lt;body marginwidth=30 marginheight=20&gt;Borrow Book&lt;/body&gt;&lt;/html&gt;", null,borrowBook.borrowBookInputs(),"Borrowing a book");
      tabs.addTab("&lt;html&gt;&lt;body marginwidth=30 marginheight=20&gt;Return Book&lt;/body&gt;&lt;/html&gt;", null,null,"Returning a book");
      tabs.addTab("&lt;html&gt;&lt;body marginwidth=30 marginheight=20&gt;Add Book&lt;/body&gt;&lt;/html&gt;", null,null,"Adding a book record");
      tabs.addTab("&lt;html&gt;&lt;body marginwidth=30 marginheight=20&gt;Delete Book&lt;/body&gt;&lt;/html&gt;", null,null,"Deleting a book record");
      tabs.addTab("&lt;html&gt;&lt;body marginwidth=30 marginheight=20&gt;Display Details&lt;/body&gt;&lt;/html&gt;", null,null,"Books and Members details");
  
      add(tabs);
      pack();
  
  }
  public static void main(String[] args) {
      GUITabbedPane frame = new GUITabbedPane();
  
      frame.setDefaultLookAndFeelDecorated(true);
      frame.setSize(800, 400);
      frame.setLocationRelativeTo(null);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
  }
  
  }
  </code></pre>
  
  <p>createAccount() which returns the panel i am display in my frame. . . </p>
  
  <pre><code>     public class TabsPanelClasses {
  
   class CreateAccount
     {
  
         JLabel label = new JLabel("Applicants` name : ");
         JTextField textField = new JTextField("New members` name here");
         JLabel label1 = new JLabel("Subscription fee ");
  
         JRadioButton radioButton1 = new JRadioButton("$25");
         JRadioButton radioButton2 = new JRadioButton("$15");
         ButtonGroup group = new ButtonGroup();
         JButton btn = new JButton("Create Account");
  
         public JPanel createAccountPanel()
         {
             JPanel panel = new JPanel(new GridLayout(3,2));
  
             panel.setBorder(new TitledBorder("Create Account"));
             panel.add(label);
             panel.add(textField);
  
  
             panel.add(label1);
             group.add(radioButton1);
             group.add(radioButton2);
  
             panel.add(radioButton1);
             panel.add(radioButton2);
             panel.add(btn);
             panel.setVisible(false);
             panel.setSize(new Dimension(50,50));
             panel.revalidate();
             panel.repaint();
  
             return panel;
  
         }
  
  
  
     }
  
  
  }
  </code></pre>