Firstly - GridBag layout does not work by setting pixel coordinates but instead is constructed proportional to other objects on the screen. See this link.
In particular it is important to understand this:
In the GridBagLayout is that there’s no way to specify the size of the grid. There doesn’t have to be. The grid size is determined implicitly by the constraints of all the objects;
An example can be seen in this image. Each 'location' on the screen is actually a relative grid position.

Secondly - Your question is oddly worded but as I understand you want to change the length of the scroll bar so it covers more of the screen. In order to change the properties of a scroll bar it is important to change ScrollBar.setPreferedSize()
. See JScrollBars.
This is the correct method to change. If setPreferedSize()
is not working then you have clearly not posted all the code. Trying checking you are not overriding it somewhere in your program (using setMaximumSize()
or by setting the size again somewhere else accidentally).
If you are not overriding it then you potentially are encountering an error with your layout manager. In your other question you seem to be manually setting your row and column sizes. This could be overriding the size of your components:
GridBagLayout gbl_ViewPane = new GridBagLayout();
gbl_ViewPane.columnWidths = new int[]{0, 0, 0, 0, 0, 222, 0};
gbl_ViewPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
gbl_ViewPane.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
gbl_ViewPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
ViewPane.setLayout(gbl_ViewPane);
Alternatively your layout manager may just be not implemented correctly or you may not be pack()
ing your scrollbar properly. If you test your code in a more isolated manner you will find that it may be a bug in your code causing the error.
Also it is important to note it is bad practice to set size manually.