Serket
Serket

Reputation: 4485

How to add a border to a Java Swing JScrollPane?

I've tried adding a border to a JScrollPane using the setBorder() method, but it didn't work. How can I add a border to a JScrollPane?

Upvotes: 0

Views: 987

Answers (1)

devDudeGS
devDudeGS

Reputation: 113

According to the JScrollPane documentation, you can use setViewportBorder to add a border around the main viewport.

scrollpane.setViewportBorder(BorderFactory.createLineBorder(Color.black));

Or you could add a border around the whole scroll pane using setBorder as outlined in this Oracle tutorial:

pane.setBorder(BorderFactory.createLineBorder(Color.black));

Upvotes: 1

Related Questions