Disable Border Of JScrollPane In Java

I thought disabling the borders of a Java Swing container would work by setting the method setBorder() to null. It does not. I happened to experience this problem after adding a JTable onto it. The only way to do this would be to create a Border object using the BorderFactory class and supplying values of zero in the createEmptyBorder() method. Check the code below.

That should do it. Now your JScrollPane (or any other Swing container) will not show any more borders.

Related Posts Plugin for WordPress, Blogger...

5 comments

  1. As an extra side note, the arguments to createEmptyBorder are optional, and default to zero, so it can be as simple as:
    jScrollPane2.setBorder(BorderFactory.createEmptyBorder());

Leave a Reply

Your email address will not be published. Required fields are marked *