Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

<identifier> expected, when using radio buttons

Posted on 2004-03-22
6
Medium Priority
?
807 Views
Last Modified: 2010-05-19
Code:

JRadioButton incomingRadio = new JRadioButton("Accept Conversation");
JRadioButton outgoingRadio = new JRadioButton("Start Conversation");
ButtonGroup connectionButtonGroup = new ButtonGroup();
connectionButtonGroup.add(incomingRadio);
connectionButtonGroup.add(outgoingRadio);

When compileing the last two lines give a '<identifier> expected' error. Yet the code seems to be correct, if I comment out those lines it compiles.
0
Comment
Question by:darrellread
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Webstorm
ID: 10653072
Hi darrellread,

Put the last 2 line in a method

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10653076
It's probably the context of those lines that is incorrect, not the lines themselves
0
 
LVL 13

Accepted Solution

by:
Webstorm earned 500 total points
ID: 10653080

In the constructor for example:

JRadioButton incomingRadio = new JRadioButton("Accept Conversation");
JRadioButton outgoingRadio = new JRadioButton("Start Conversation");
ButtonGroup connectionButtonGroup = new ButtonGroup();

public <yourclassname>()
{
    connectionButtonGroup.add(incomingRadio);
    connectionButtonGroup.add(outgoingRadio);
}

Because you cannot call a method within class member declaration.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 10653104
What is the very next thing that comes after those lines darrellread?
0
 

Author Comment

by:darrellread
ID: 10653107
Stupid Me, Excellent thanks for your help. Very Quick Response.
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 10653140
:-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question