
How to add tabs in right side of a window from top to bottom in swings

Here is a code that add tabs in right side of a window from top to bottom in swings.
import javax.swing.*;
import java.awt.*;
public class SetTabLocation extends JPanel {
public SetTabLocation() {
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(400, 200));
JTabbedPane pane = new JTabbedPane(JTabbedPane.RIGHT);
pane.addTab("Tab 1", new JPanel().add(new JLabel("This is Tab 1")));
pane.addTab("Tab 2", new JPanel().add(new JLabel("This is Tab 2")));
pane.addTab("Tab 3", new JPanel().add(new JLabel("This is Tab 3")));
this.add(pane, BorderLayout.CENTER);
}
public static void main(String[] args) {
JPanel panel = new SetTabLocation();
panel.setOpaque(true);
JFrame frame = new JFrame("JTabbedPane Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.