JScrollPane - strange repainting problem?
- From: lmierzej <lmierzej@xxxxx>
- Date: Mon, 24 Oct 2005 14:50:46 +0200
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 .
- Follow-Ups:
- Re: JScrollPane - strange repainting problem?
- From: Vova Reznik
- Re: JScrollPane - strange repainting problem?
- From: Andrew Thompson
- Re: JScrollPane - strange repainting problem?
- Prev by Date: Re: HTML in Java
- Next by Date: Re: HTML in Java
- Previous by thread: Translate char to virtual key code to set mnenonic
- Next by thread: Re: JScrollPane - strange repainting problem?
- Index(es):