How to increase JScrollPane panel size?

scrollPane = new JScrollPane(table); panel1.add( scrollPane,BorderLayout.CENTER ); 

Is there a way to make scrollPane bigger (wider)?

+2
source share
3 answers
 JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setPreferredSize(new Dimension(40, 0)); 

It works. I get it.

+5
source

When using Border Layout, you do not control the size of somont in it. Consider using the GridBag Layout .

+2
source

JScrollPane is as big as the item it contains. You must make these elements wider.

In addition, there is a setSize() method. But you most likely want to use the setPreferredSize() method, as indicated by mre.

+1
source

Source: https://habr.com/ru/post/1243214/


All Articles