Solved

<identifier> expected, when using radio buttons

Posted on 2004-03-22
6
754 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 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Eclipse Neon and jdk 1.8.0 11 69
Problem to start Neon 20 53
mockito example issue 8 35
Java Loop 4 14
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now