java - Adding array of JRadioButtons with variable length to a JWindow -


Hi All I was trying to add an array of variable length to JWindow but I'm getting a run time error. Get help from here ..

Here's my code:

  package element; Import java.util.Calendar; Public class extended up to javax.swing.JWindow {Public Foladi () {initComponents (); } Private Zero initComponents () {int i; // To get the number of days of the current month Calendar cal = calendar.justinstance (); Integer = max. (Calendar DAY_OF_MONTH); GetContentPane () SetLayout (new Java.att.flowout ()); // Creating any size Rediobuton equal time to present (i = 0; i & lt; maxdays; i ++) {jRadioButton [maxdays] = new javax.swing.JRadioButton (); . GetContentPane () add (jRadioButton [i]); } Pack (); } Public static zero main (string exits []) {Java.ew.quintacuyue.acquelkiller (new runnabl) (public zero-less) (new flowery ()) setwub (true);}}); } Private javax.swing.JRadioButton jRadioButton []; }   

But what I get error is:

  exception in thread "AWT-EventQueue-0" java.lang.NullPointerException components.FullDay On. InitComponents (FullDay.java.1) on Components.FullDay & Lt; Init & gt; (FullDay.java:8) components.FullDay $ 1.run (FullDay.java.30) on java.awt.event.InvocationEvent.dispatch (java.awt.EventQueue.dispatchEvent (unknown unknown Java.awt.EventDispatchThread.pumpOneEventForFilters Source (Java) .vent Dispatches .jpg.vt.EventDispatchThread.pumpEventsForHierarchy (unknown source) on pumpEventsForFilter (unknown source) on Java.awt.EventDispatchThread.pumpEvents (unknown source) java.awt.EventDispatchThread on .pumpEvents (unknown source) at java.awt.EventDispatchThread.run (unknown source)    

< P> Instead of always starting the previous one, i-th of the array Fields might want to initialize are:
  Jeardiobtn [i] = new javax.swing.JR adioButton ();   

Instead of:

  jRadioButton [maxdays] = new javax.swing.JRadioButton ();   

in addition, as stated in the previous answer, create the array out of the loop .

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -