How to get rid of the border with a JTable / JScrollPane?

Use BorderFactory. CreateEmptyBorder() instead of null by using: sp. SetBorder(createEmptyBorder()) it works Your main method becomes: public static void main(String args) { JFrame frame = new TestScrollPane(); JPanel panel = new JPanel(); JTable table = new JTable(); panel.

SetLayout(new BorderLayout()); panel. Add(new JLabel("NORTH"), BorderLayout. NORTH); panel.

Add(new JLabel("SOUTH"), BorderLayout. SOUTH); JScrollPane sp = new JScrollPane(table); sp. SetBorder(BorderFactory.

CreateEmptyBorder()); panel. Add(sp, BorderLayout. CENTER); frame.

Add(panel); frame. SetVisible(true); }.

Use BorderFactory. CreateEmptyBorder() instead of null... by using: sp. SetBorder(createEmptyBorder()); it works.

Your main method becomes: public static void main(String args) { JFrame frame = new TestScrollPane(); JPanel panel = new JPanel(); JTable table = new JTable(); panel. SetLayout(new BorderLayout()); panel. Add(new JLabel("NORTH"), BorderLayout.

NORTH); panel. Add(new JLabel("SOUTH"), BorderLayout. SOUTH); JScrollPane sp = new JScrollPane(table); sp.

SetBorder(BorderFactory. CreateEmptyBorder()); panel. Add(sp, BorderLayout.

CENTER); frame. Add(panel); frame. SetVisible(true); }.

Thanks! Looks fine now. :) – Dan Howard Jul 26 '10 at 9:52 1 Cool :).

I think (but not sure) the default behavior of swing components is to have line border. So the BorderFactory class is your friend to customize them :) – Sylvain M Jul 26 '10 at 10:08 Very good answer! Fixed my problem as well!

– Handsken Oct 4 at 11:42.

Interestingly the border disappears when you remove this line: sp. SetBorder(null).

Not for me with windows XP. Maybe it's a platform issue. – Dan Howard Jul 26 '10 at 9:52.

I think the proper fix is to set the border on the viewportView to 'null'.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions