java: how to make srollable panel with radio button and labels inside?

Posted by Lucia on Stack Overflow See other posts from Stack Overflow or by Lucia
Published on 2010-05-17T19:29:30Z Indexed on 2010/05/17 19:50 UTC
Read the original article Hit count: 180

Filed under:
|
|

Hi,

I got a JScrollPane in which I want to place a list of radio buttons and labels. My problem is the panel doesn't scroll, I suppose it's because i didn't set a viewport, but how can I set it when I have to many components? My code looks something like this:

JScrollPane panel = new JScrollPane();
JRadioButton myRadio;
JLabel myLabel;
for(int i = 0; i<100; i++){
    myRadio = new JRadioButton();
    myLabel = new JLabel("text");
    panel.add(myRadio);
    panel.add(myLabel);
 }

Thanks.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing