java 设置滑动条位置,Swing JScrollPane-如何将垂直滚动条设置到左侧?

本文讨论了在Java Swing中遇到的一个问题,即设置组件方向为RIGHT_TO_LEFT后,滚动条行为异常。提供了一个示例代码展示问题,并提及已向Oracle提交bug报告。解决方案包括使用ComponentOrientation在初始化布局后进行切换以获得正确布局。
摘要由CSDN通过智能技术生成

See the title. I've tried to change component orientation to RIGHT_TO_LEFT, but that had a unexpected side effect - it behaves strangely with components with specified preferred size.

(JDK 1.6.0_23, Eclipse VE)

EDIT

Here is the example of this:

We have JFrame with jMainScrollPane on it. Inside jMainScrollPane we place a jMainPanel. Now set jMainPanel's preferred size to be narrower than jMainScrollPane's. jMainPanel will still take all the space on jMainScrollPane. Now changejMainScrollPane's orientation to RIGHT_TO_LEFT and see what happen.

Sample code (change jMainScrollPane's orientation to see the difference):

import java.awt.BorderLayout;

import java.awt.ComponentOrientation;

import java.awt.Dimension;

import javax.swing.BoxLayout;

import javax.swing.JFrame;

import javax.swing.JPanel;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值