如何在Java中创建垂直制表符?
我想获得像 JTabbedPane 逆时针旋转 90 度的效果(只有选项卡,而不是选项卡内的内容)。在 Java 中实现这一点的最佳方法是什么?
I would like to get the effect like if JTabbedPane would be turned 90 degrees counterclockwise (only tabs but not the content inside tabs). What is the best way to implement that in Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在此解决方案中:
http://oreilly.com/pub/a /mac/2002/03/22/vertical_text.html
文本垂直绘制并尝试作为选项卡上的图标。这样您就不必修改 JTabbedPane,只需在选项卡中使用自定义图标即可。
当然,您还必须指定选项卡位置位于左侧。
In this solution:
http://oreilly.com/pub/a/mac/2002/03/22/vertical_text.html
The text was painted vertically and tried as an icon on the tab. This way you don't have to modify JTabbedPane you just use a custom Icon in the tab.
Of course you would also have to specify the tab placement to be on the Left.
您可以在构造函数中指定位置:
http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#JTabbedPane%28int%29
或在设置器中:
http: //download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#setTabPlacement%28int%29
You can specify the placement in the constructor:
http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#JTabbedPane%28int%29
or in the setter:
http://download.oracle.com/javase/6/docs/api/javax/swing/JTabbedPane.html#setTabPlacement%28int%29
您可以尝试
setTabPlacement(SwingConstants.LEFT)
或此组件You can try
setTabPlacement(SwingConstants.LEFT)
or this component作为替代方案,请考虑
JToolBar
在BorderLayout
、EAST
或WESTorientation
设置为VERTICAL
代码>.在按钮的中旋转文本相当简单>图标
。As an alternative, consider
JToolBar
withorientation
set toVERTICAL
in aBorderLayout
,EAST
orWEST
. It's fairly easy rotate text in the button'sIcon
.您可以尝试扩展 tabpane 类,在重载的绘制方法中,获取图形对象,假设
g2d
是重载的绘制方法的参数:作为启动器
You could try and extend the tabpane class, in the overloaded paint method, get the graphics object, say
g2d
is the argument of the overloaded paint method:as a starter