Deselecte radioknapper
Jeg har 10 radioknapper i et javaprogram, som alle tilhører samme gruppe. Det fremgår af følgende udsnit af koden:procent10 = new JRadioButton("10%");
procent20 = new JRadioButton("20%");
procent30 = new JRadioButton("30%");
procent40 = new JRadioButton("40%");
procent50 = new JRadioButton("50%");
procent60 = new JRadioButton("60%");
procent70 = new JRadioButton("70%");
procent80 = new JRadioButton("80%");
procent90 = new JRadioButton("90%");
procent100 = new JRadioButton("100%");
ButtonGroup hastighed = new ButtonGroup();
hastighed.add(procent10);
hastighed.add(procent20);
hastighed.add(procent30);
hastighed.add(procent40);
hastighed.add(procent50);
hastighed.add(procent60);
hastighed.add(procent70);
hastighed.add(procent80);
hastighed.add(procent90);
hastighed.add(procent100);
Jeg kunne godt tænke mig at lave en metode der sørger for at ingen af radioknapperne er valg. Jeg kunne selvfølgelig deSelecte dem en for en vha. metoden setSelected(false). Men er der ikke en nemmere og hurtigere måde?
På forhånd tak
Hono
