如何让水平JScrollBar的默认位置在右侧?
我正在开发一个程序,默认情况下水平滚动条应该位于右侧位置,我尝试使用 Viewport()
但它不起作用。有什么想法吗?
jScrollPane4.getViewport().setViewPosition(new Point(10, 10));
BoxLayout boxlayout = new BoxLayout(categoryPanel, BoxLayout.Y_AXIS);
BoxLayout boxlayout2 = new BoxLayout(servicePanel, BoxLayout.Y_AXIS);
categoryPanel.setLayout(boxlayout);
category cg = new category();
subString ss = new subString();
try {
List<JButton> buttonList = new ArrayList<>();
List<Category> map = cg.readDatafromJson();
for (Category item : map) {
String CAr = ss.SubString(item.getName_ar());
String SAr = ss.SubString(item.getName_en());
JButton button = new JButton("<html><p style=\"text-align:right;\"><b>" + CAr + "</b> \n" + SAr + "</P></html>", icon);
Border line = new LineBorder(Color.BLACK);
button.setActionCommand(item.getKey());
button.setHorizontalAlignment(SwingConstants.RIGHT);
button.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
buttonList.add(button);
categoryPanel.add(button);
categoryPanel.revalidate();
categoryPanel.repaint();
}
} catch (IOException ex) {
Logger.getLogger(PassOrdreCashier.class.getName()).log(Level.SEVERE, null, ex);
}
滚动条
I have a program I am working on, the horizontal scrollbar should be in the right-hand position by default, I tried to use Viewport()
but it doesn't work. Any ideas?
jScrollPane4.getViewport().setViewPosition(new Point(10, 10));
BoxLayout boxlayout = new BoxLayout(categoryPanel, BoxLayout.Y_AXIS);
BoxLayout boxlayout2 = new BoxLayout(servicePanel, BoxLayout.Y_AXIS);
categoryPanel.setLayout(boxlayout);
category cg = new category();
subString ss = new subString();
try {
List<JButton> buttonList = new ArrayList<>();
List<Category> map = cg.readDatafromJson();
for (Category item : map) {
String CAr = ss.SubString(item.getName_ar());
String SAr = ss.SubString(item.getName_en());
JButton button = new JButton("<html><p style=\"text-align:right;\"><b>" + CAr + "</b> \n" + SAr + "</P></html>", icon);
Border line = new LineBorder(Color.BLACK);
button.setActionCommand(item.getKey());
button.setHorizontalAlignment(SwingConstants.RIGHT);
button.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
buttonList.add(button);
categoryPanel.add(button);
categoryPanel.revalidate();
categoryPanel.repaint();
}
} catch (IOException ex) {
Logger.getLogger(PassOrdreCashier.class.getName()).log(Level.SEVERE, null, ex);
}
Scrollbar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论