Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

<identifier> expected, when using radio buttons

Posted on 2004-03-22
6
Medium Priority
?
804 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 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

730 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