[英]java swing TabbedPane position tabheaders bottom right to left
I wonder if there is any possibility to position a Tabbed pane to the bottom right, I want to make to containers above each other, the one with the tablabels at the top right to left (no problem/default), and the other one with the tablabels at bottom (so far so good) starting from right to left. 我想知道是否有可能将“选项卡式”窗格放在右下角,我想使容器彼此上方,一个带有tablabels到右上角的容器(没有问题/默认),另一个带有底部的tablabel(到目前为止非常好)从右到左开始。 The design I imagine is:
我想象的设计是:
| tab display |
| tab display |
| tab display |
-----------------------------------------------
_________________________ | tab top | another|
| Bottom Tab| Second Tab|______________________
| |
well, my ascy drawing capabilities are limited but I hope you get the picture. 好吧,我的ascy绘图功能有限,但希望您能理解。 Is there any way, in wich I can add a layout manager to a tabbed pane to layout the tablabels?
有什么办法可以将布局管理器添加到选项卡式窗格以布局tablabel? Where can I find an example of such?
在哪里可以找到这样的例子? Goodling suggested to just use a menubar in combination with a CardLayout for the tabbed panes.
Goodling建议仅将选项卡栏与CardLayout结合使用。 However I have no clue how to draw a menubar so that it looks like tabs.
但是我不知道如何绘制菜单栏,使其看起来像选项卡。 (I just peeked into the swingtrail for custom drawing but it just goes on about the general possibility, besides If I do so I loose the styling capabilities. The only thing I can think off right now is to use a tabbed pane with no content and make it controll another container with a card layout via eventlisteners.
(我只是窥视了用于自定义图纸的吊架,但这只是一般性的可能性,此外,如果我这样做的话,我会失去样式功能。我现在唯一能想到的就是使用没有内容的选项卡式窗格,并且通过事件侦听器控制卡片布局的另一个容器。
Any suggestions? 有什么建议么?
PS: I have to implement the solution with java 1.6 PS:我必须用Java 1.6实现解决方案
In this case you can to set ComponentOrientation for JTabbedPane 在这种情况下,您可以为JTabbedPane设置ComponentOrientation
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
public class TestTabbedPane extends JFrame {
private static final long serialVersionUID = 1L;
private JTabbedPane tabbedPane;
public TestTabbedPane() {
tabbedPane = new JTabbedPane();
tabbedPane.setPreferredSize(new Dimension(300, 200));
getContentPane().add(tabbedPane);
JPanel panel = new JPanel();
tabbedPane.add(panel, "null");
JTextField one = new JTextField("one");
tabbedPane.add(one, "one");
JTextField two = new JTextField("two");
//tabbedPane.add(two, "<html> T<br>i<br>t<br>t<br>l<br>e <br> 1 </html>");
tabbedPane.add(two, "<html> Tittle 1 </html>");
tabbedPane.setEnabledAt(2, false);
tabbedPane.setTitleAt(2, "<html><font color="
+ (tabbedPane.isEnabledAt(2) ? "black" : "red") + ">"
+ tabbedPane.getTitleAt(2) + "</font></html>");
tabbedPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
}
public static void main(String args[]) {
TestTabbedPane frame = new TestTabbedPane();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
check with setTabPlacement(JTabbedPane.TOP) method available are TOP , LEFT , BOTTOM , RIGHT 使用setTabPlacement(JTabbedPane.TOP)方法检查是否可用TOP,LEFT,BOTTOM,RIGHT
http://www.exampledepot.com/egs/javax.swing/tabbed_TpTabLoc.html http://www.exampledepot.com/egs/javax.swing/tabbed_TpTabLoc.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.