Solved

<identifier> expected, when using radio buttons

Posted on 2004-03-22
6
789 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 125 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
Technology Partners: 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

734 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