Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding array of JRadioButtons with variable length to a JWindow
    primarykey
    data
    text
    <p>Hello everyone I was trying to add an array of variable length to a JWindow but I am getting a run time error. Want help from here ..</p> <p>Here is my code : </p> <pre><code> package components; import java.util.Calendar; public class FullDay extends javax.swing.JWindow { public FullDay() { initComponents(); } private void initComponents() { int i; //to get the no of days of the current month. Calendar cal = Calendar.getInstance(); int maxdays = cal.getActualMaximum(Calendar.DAY_OF_MONTH); getContentPane().setLayout(new java.awt.FlowLayout()); //Creating an array of radiobuttons having size equal to the no of days of the current //month for(i=0; i&lt;maxdays; i++) { jRadioButton[maxdays] = new javax.swing.JRadioButton(); getContentPane().add(jRadioButton[i]); } pack(); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FullDay().setVisible(true); } }); } private javax.swing.JRadioButton jRadioButton[]; } </code></pre> <p>But the error I am getting is :</p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at components.FullDay.initComponents(FullDay.java:18) at components.FullDay.&lt;init&gt;(FullDay.java:8) at components.FullDay$1.run(FullDay.java:30) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload