Hi I am creating a program in which I have 2 tabs. I want to make my tabs bigger in size so they can take whole panel space. Is there any way I can make both tabs size bigger. thanks

import java.awt.*;
    import static java.awt.Font.BOLD;
    import java.awt.event.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import javax.swing.*;
    import static javax.swing.SwingConstants.CENTER;
    import javax.swing.border.*;
    import javax.swing.event.*;



    public class hotels extends JFrame{

        JButton hotel;
        JLabel image;
         JTabbedPane tabbed,tabbed1;
        JPanel panel;
        JPanel panel1;

        Container pane;
        JPanel panel2;
        JLabel departure;
        JLabel from;
        JLabel to;


        public hotels(){


             panel=new JPanel();
            panel.setBackground(Color.cyan);
            hotel=new JButton();
            hotel.setText("Hotels");

            Font myFont = new Font("Serif", Font.BOLD, 18);


            hotel.setFont(myFont);
            panel.setLayout(null);
            panel.add(hotel);

            hotel.setBounds(50, 80, 100, 40);


            image=new JLabel();

            image.setBounds(50,1,80,80);
            image.setBorder(BorderFactory.createLineBorder(Color.yellow));
            image.setBackground(Color.white);
            image.setIcon(new ImageIcon("2.gif"));
            panel.add(image);

           panel1=new JPanel();
            panel1.setLayout(null);

          tabbed=new JTabbedPane();

             tabbed.setBounds(10, 110, 20, 20);

             tabbed.setBorder(BorderFactory.createMatteBorder(24, 6, 12, 6, Color.blue));

              Font myFont1 = new Font("Serif", Font.BOLD, 18);
              tabbed.setFont(myFont1);

             tabbed.setBorder(BorderFactory.createTitledBorder("Search Flights"));

         tabbed.add( "Round Trip",panel1);

         panel2=new JPanel();
         panel2.setLayout(null);
         panel2.setBackground(Color.white);
         departure=new JLabel();
         departure.setText("Departure");

         Font f=new Font("Serif", Font.PLAIN,12);
         departure.setBounds(50,1,80,80);
         departure.setFont(f);
         panel2.add(departure);
           tabbed.add("One Way",panel2);
           from=new JLabel();
           from.setBackground(Color.blue);

           panel1.setBackground(Color.yellow);



            pane=getContentPane();


              pane.add(panel);

       image.addMouseListener(new MouseAdapter()

       {

          public void mouseClicked(MouseEvent e){
               if (e.getSource()==image){

          pane.removeAll();

          pane.add(tabbed);
          pane.revalidate();
          pane.repaint();

               }


           }


       }


       );

        }



        public static void main(String[] args) {

     hotels mw=new hotels();
      mw.setVisible(true);
      mw.setSize(300, 400);


        }



        }

Edited 1 Year Ago by ali11

Since you are using a null layout manager you can setBounds to make things whatever size you want. What happens when you run your program on a Mac with a "retina" display is another question...

thanks i already use tabbed.setBounds(0, 20, 80, 40); but nothing change

I give that number just an example I try bigger too but the result is same.

This article has been dead for over six months. Start a new discussion instead.