LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2004, 09:03 AM   #1
linux_ub
Member
 
Registered: May 2004
Location: NY
Distribution: fedora core 1
Posts: 65

Rep: Reputation: 18
help with JRadioButton Action listeners


Hi

i have a class which is being used to add a question followed by several choices like a multiple choice question. the choices are listed using JRadioButton.
Code:
	public Choices(String labelText, int noOfRB, String[] radioButtonText) {
		label = new JLabel(labelText);		
		group = new ButtonGroup();		
		panel = new JPanel();		
		panel.setLayout(new FlowLayout());		
		panel.add(label);		
		radioButtons = new JRadioButton[noOfRB];	
		for (int i=0; i<noOfRB; i++) {			
				radioButtons[i] = new JRadioButton(radioButtonText[i]);
				panel.add(radioButtons[i]);	
				group.add(radioButtons[i]);radioButtons[i].addActionListener(this);
		}
}
tha addActionListner piece of code gives me the following error
" the method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (Choices)

could any one please help my finding my mistake

thanks
 
Old 09-13-2004, 01:59 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337

Rep: Reputation: 65
Can't see any error right away, but I found this at Sun homepage:

http://java.sun.com/docs/books/tutor...ts/button.html

the only thing different that I can see, is that in this case, they have the amount of buttons defined from the beginning, but I doubt it has anything to do with your for >> next loop. Anyway, take a look into the example

Good luck!
 
Old 09-14-2004, 01:44 PM   #3
linux_ub
Member
 
Registered: May 2004
Location: NY
Distribution: fedora core 1
Posts: 65

Original Poster
Rep: Reputation: 18
its the same tutorial i am using to write my piece of code ... but no success till now

thanks neways
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Unable to establish ICE Listeners: Cannot Socket..." Error!!! cqmyg5 Slackware 6 04-15-2012 12:37 AM
Select problem with multiple listeners Fruitbat Programming 3 04-29-2005 12:24 PM
See CL in Action 2 Xterminator Conectiva 0 06-30-2003 10:14 AM
affirmative action? fragged one General 25 01-23-2003 09:37 PM
See CL 8 in action Xterminator Conectiva 1 09-26-2002 12:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration