I am using a JTabbedPane with three buttons. The program is running fine except that the buttons remains small even if you resize the window. Is there a way of setPrefferedSize for them?

here is the code if it helps:

public final class JTabbedPaneDemo {

    JFrame frame;
    JTabbedPane pane;
    JPanel panel1;
    JPanel panel2;
    JPanel panel3;


    JTabbedPaneDemo(){

    this.createFrameGUI("My Tabbed Pane");

    }
    //creating the frame
    public void createFrameGUI(String title){
    frame= new JFrame(title);
    frame.setSize(new Dimension(350,350));
    frame.setVisible(true);
    frame.setLayout(new BorderLayout());

    //create the the tabs
    this.createPanel1();
    this.createPanel2();
    this.createPanel3();

    //create the tabbed pane
    pane= new JTabbedPane();
    pane.addTab("Pane 1", panel1);
    pane.addTab("Pane 2", panel2);
    pane.addTab("Pane 3", panel3);

    //add the pane to the frame
    frame.add(pane,BorderLayout.CENTER);
    }


    //creating the tabs
    public void createPanel1(){
    panel1= new JPanel();
    panel1.setLayout(new BorderLayout());
    panel1.add(new JButton("we are in panel 1"));
    panel1.setPreferredSize(new Dimension(300,300));
    }
      public void createPanel2(){
    panel2= new JPanel();
    panel2.setLayout(new BorderLayout());
    panel2.add(new JButton("we are in panel 2"));
    panel2.setPreferredSize(new Dimension(300,300));
    }
    public void createPanel3(){
    panel3= new JPanel();
    panel3.setLayout(new BorderLayout());
    panel3.add(new JButton("we are in panel 3"));
    panel3.setPreferredSize(new Dimension(300,300));
    }
    public static void main(String [] args){

    JTabbedPaneDemo dem= new JTabbedPaneDemo();

    }
}

Hi guys,

Thanks for the ideas, they worked perfect. I really wanted it the way it is done in the second link posted by Stultuske. I did not know HTML would work here but that is really what i have been looking for.
it goes this way:myTabbedPane.addTab("<html><body leftmargin=15 topmargin=8 marginwidth=15 marginheight=5>Tab1</body></html>", new JLabel("Text Component 1"));

You guys are great, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.