Java Program to display JTabbedPane on the right

Java 8Object Oriented ProgrammingProgramming

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

raja
Published on 31-May-2019 11:34:59
Advertisements