简体   繁体   English

如何在JTabbedPane及其组件之间添加JSplitPane?

[英]How to add JSplitPane between the JTabbedPane and its components?

This is my code given below as: 这是我的代码如下:

theJTabbedPane.addTab(CODING, new javax.swing.ImageIcon(getClass().getResource("/com/sysvine/healthpractice/gui/images/tablet.png")), aPanelDiagIcd);//Constant.getTextBundle("5.การวินิจฉัย")
    aPanelDiagIcd.addPanel(Constant.getTextBundle("การลงรหัส ICD-10"), aPanelDiagICD10);
    aPanelDiagIcd.addPanel(Constant.getTextBundle("การลงรหัส ICD-9"), aPanelDiagICD9);

I need to add JSplitPane between JTabbedPane and its component. 我需要在JTabbedPane及其组件之间添加JSplitPane The tabbed pane consists of 9 tabs. 选项卡式窗格包含9个选项卡。 In that each tab consists of different functionality with different panel. 因为每个选项卡由具有不同面板的不同功能组成。 But they added that the tabbed pane. 但是他们添加了选项卡式窗格。 How Can I set split pane between them, and what will be the left and right component for split pane? 如何设置它们之间的拆分窗格,拆分窗格的左右组件是什么?

splitPaneH= new javax.swing.JSplitPane();
splitPaneH.setOrientation(javax.swing.JSplitPane.HORIZONTAL_SPLIT);

splitPaneH.setDividerLocation(0);
splitPaneH.setOneTouchExpandable(true);
splitPaneH.setLeftComponent( theJTabbedPane  );
//splitPaneH.setRightComponent( aSourceTabbedPane  );

You can't separate the tabs from their contents with another component like a JSplitPane . 您无法使用JSplitPane类的其他组件将选项卡与其内容分开。

However you can tell the JTabbedPane how and where you want your tabs to be layed out. 但是,您可以告诉JTabbedPane如何以及在何处布局标签。 Look at the constructors JTabbedPane(int tabPlacement) and JTabbedPane(int tabPlacement, int tabLayoutPolicy) (there are also setters/getters for these). 查看构造函数JTabbedPane(int tabPlacement)JTabbedPane(int tabPlacement, int tabLayoutPolicy) (也有这些设置器/获取器)。

For tab placement use JTabbedPane.LEFT , or JTabbedPane.RIGHT and the result will be what you want to achieve. 对于选项卡放置,请使用JTabbedPane.LEFTJTabbedPane.RIGHT ,结果将是您想要实现的。

If you have too many tabs, you can choose between JTabbedPane.WRAP_TAB_LAYOUT or JTabbedPane.SCROLL_TAB_LAYOUT . 如果选项卡太多,则可以在JTabbedPane.WRAP_TAB_LAYOUTJTabbedPane.SCROLL_TAB_LAYOUT之间进行选择。 The first will display all tabs in multiple rows/cols if needed, the latter one will only display as many that fits into the space and display scroll buttons to scroll to the not visible tabs. 第一个将在需要时以多行/列显示所有选项卡,后一个将仅显示适合该空间的尽可能多的选项卡,并显示滚动按钮以滚动到不可见的选项卡。

IF you really want to separate tabs from their contents with something like a JSplitPane , you can't use JTabbedPane for this. 如果您真的想使用诸如JSplitPane类的选项卡将其标签与它们的内容分开,则不能使用JTabbedPane You have to implement that yourself. 您必须自己实现。 Eg put buttons (representing the tabs) on one side of a JSplitPane , and when those buttons are clicked, change the component on the other side of the JSplitPane . 例如,将按钮(代表选项卡)放在JSplitPane一侧,然后单击这些按钮,则更改JSplitPane另一侧的组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM