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