Link to home
Start Free TrialLog in
Avatar of sabi97
sabi97

asked on

JTabbedPane Layout

Hi,

What is the correct way to set the layout for a JTabbedpane? I'm getting errors when I use :

panel1.setLayout(new BorderLayout() );    
panel1.add(new JButton("Enter"),BorderLayout.SOUTH);

-----------------------------

Full code below :


import javax.swing.*;
import java.awt.event.*;
   
    public class Grads {
    public static void main(String args[]) {
            JFrame frame = new JFrame("Database");
       
   frame.addWindowListener(new
                      WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
   
            JPanel panel1 = new JPanel();  
            JPanel panel2 = new JPanel();
            JPanel panel3 = new JPanel();
            JPanel panel4 = new JPanel();
           
           
 panel1.setLayout(new BorderLayout() );    
 panel1.add(new JButton("Enter"),BorderLayout.SOUTH);

            JTabbedPane jtp = new JTabbedPane();                        
            jtp.add("Search", panel1);
            jtp.add("Email", panel2);
            jtp.add("Management", panel3);
            jtp.add("Notes", panel4);
           
         
            frame.getContentPane().add(jtp);
            frame.setLocation(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    }

ASKER CERTIFIED SOLUTION
Avatar of stimpyjcat
stimpyjcat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sabi97
sabi97

ASKER

Thanks! Worked well!