1

I am creating a JFrame Form in Netbeans. I have an Employee table in database. What I am trying to do that when this page loads, it will display employees record row-wise in jframe form. I have dragged JPanel to JFrame, and added radiobuttons(for testing purposes only) into JPanel. But It is not displaying Radiobuttons which are generated at run-time!!! Is there anyway I can accomplish this? Here is my code:

public class ShowEmployees extends javax.swing.JFrame {

/** Creates new form ShowEmployees */
public ShowEmployees() {
    initComponents();

    for (int i = 0; i < 10; i++)
    {
        JRadioButton textField = new JRadioButton();
        this.jPanel1.add( textField );
    }
    this.jPanel1.validate();
}
...
}
kleopatra
  • 51,061
  • 28
  • 99
  • 211
Azeem
  • 2,904
  • 18
  • 54
  • 89
  • I would ask you consider a different approach: display the records in a JTable. This would even allow use of radiobuttons if done right. Otherwise, yes JRadioButtons can easily be added to a JPanel but you must make sure that the JPanel uses the right layout manager, here a GridLayout. I strongly urge you to read the Swing tutorials as they will tell you all you need to know to do this. – Hovercraft Full Of Eels Feb 01 '12 at 18:07

0 Answers0