在右侧显示 JTabbedPane 的 Java 程序
要将 JTabbedPane 显示在右侧,你需要使用常量 RIGHT− 来将位置设置为右侧
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);
以下是如何在右侧显示 JTabbedPane 的示例−
示例
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); } }
输出
广告