JScrollPane - strange repainting problem?



Hi,

why JScrollPane is not repainting like other components (like JButton)?

repaint()on main frame doesn't work on JScrollPane, only setVisible(true) on main frame works well

could anyone help? (there is a quick, working code example below)

thanks very much in advance for your help!


CODE SAMPLE: import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants;

public class ScrollPaneTest extends JFrame{
	
	public ScrollPaneTest() {
		
		this.setLayout(null);
		
		this.setBounds(100,100,300,300);
		this.setVisible(true);
		
		//JScrollPane begin
		JScrollPane scrollPane = new JScrollPane();
		
		JLabel label = new JLabel("This is JLabel!");
		scrollPane.setViewportView(label);
		
		scrollPane.setBounds(50,50,80,80);
		scrollPane.setVerticalScrollBarPolicy(
			ScrollPaneConstants.
			VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setHorizontalScrollBarPolicy(
			ScrollPaneConstants.
			HORIZONTAL_SCROLLBAR_ALWAYS);
		
		this.getContentPane().add(scrollPane);
		//JScrollPane end
		
		
		//JButton begin
		JButton button = new JButton();
		
		button.setBounds(50,200,50,50);
		
		this.getContentPane().add(button);
		//JButton end
		
		this.repaint(); //JScrollPane content is blank!
		
		//But setVisible(true) makes everything ok.
	}

	public static void main(String[] args) {
		
		new ScrollPaneTest();
	}
	
}

regards,
lmierzej
.