Search code examples
javaswingjscrollpane

padding of JTable via JScrollPane


I have JTable in JScrollPane.

JTable table = new JTable(data, columnNames);
JScrollPane scroll = new JScrollPane();
scroll.setViewportView(table);

everything is well, but If I need to be more space between Scrollpanel and table? how can I do that? for example: in HTML/CSS if we use <div> tag, we have "padding" method. I need something like that.


Solution

  • another solution is

    setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder()));
    

    it does not deletes black lines around the component too, which is inside the ScrollPanel.