Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. removing jRadioButton automatically in java
  2. // bg: buttonGroup
  3.  
  4. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  5.     int count = -1;
  6.     for (Enumeration e=bg.getElements(); e.hasMoreElements(); ) {
  7.         JRadioButton b = (JRadioButton)e.nextElement();count++;
  8.         if (b.getModel() == bg.getSelection()) {
  9.             bg.remove(b);
  10.             jPanel1.remove(jPanel1.getComponent(count));
  11.         }
  12.     }
  13. }
  14.        
  15. jPanel1.revalidate();
  16. jPanel1.repaint();