• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null pointer exception Radiobuttons

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


==============


Any ideas where I went wrong ?
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there I see four potential issues

- use Swing JComponent rather than AWT (Choice and Label), don't to mix AWT with Swing

- you forgot to intialize JRadioButton b0,b5,b10,b20;

- main class isn't proper ( something - public static void main(String[] args) { )

- read Oracle tutorial Initial Thread
 
Harshit R Shah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

m Korbel wrote:there I see four potential issues

- use Swing JComponent rather than AWT (Choice and Label), don't to mix AWT with Swing

- you forgot to intialize JRadioButton b0,b5,b10,b20;

- main class isn't proper ( something - public static void main(String[] args) { )

- read Oracle tutorial Initial Thread



Can you tell me how to initialize the buttons.I am in a fix and am totally new to AWT/swing programs
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harshitsss Shah wrote:
Can you tell me how to initialize the buttons.I am in a fix and am totally new to AWT/swing programs


Using JRadionButtons is pretty simple. Here I googled for you:

- From the Java tutorial: How to Use Buttons, Check Boxes, and Radio Buttons

- From the web: JRadioButton basic tutorial and examples

Hope that helps.
 
Marshal
Posts: 79240
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harshitsss Shah wrote: . . . Can you tell me how to initialize the buttons. . . .

Same way you initialise any other references. Preferably in the constructor.

Don't try to squeeze so many declarations into one line, and leave some spaces. I doubt whether those buttons need to be fields'; they can probaboy be local variables in the constructor/initGUI method.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lines 65-99 should be after all those other create statements. You add the buttons to the panel last just before adding the panel to the frame.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic