Java Program to display JTabbedPane on the right


To display JTabbedPane on the right, you need to set the location to the right using the constant RIGHT −

JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);

The following is an example to display JTabbedPane on the right −

Example

package my;
import javax.swing.*;
public class SwingDemo {
   public static void main(String args[]) {
      JFrame frame = new JFrame("Technologies");
      JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);
      JPanel panel1, panel2, panel3, panel4, panel5;
      panel1 = new JPanel();
      panel2 = new JPanel();
      panel3 = new JPanel();
      panel4 = new JPanel();
      panel5 = new JPanel();
      tabbedPane.addTab("PHP", panel1);
      tabbedPane.addTab("Blockchain ", panel2);
      tabbedPane.addTab("Matlab", panel3);
      tabbedPane.addTab("JSP ", panel4);
      tabbedPane.addTab("Servlet", panel5);
      frame.add(tabbedPane);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(550,350);
      frame.setVisible(true);
   }
}

Output

Updated on: 30-Jul-2019

74 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements