• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 808
  • Last Modified:

<identifier> expected, when using radio buttons

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
darrellread
Asked:
darrellread
  • 3
  • 2
1 Solution
 
WebstormCommented:
Hi darrellread,

Put the last 2 line in a method

0
 
CEHJCommented:
It's probably the context of those lines that is incorrect, not the lines themselves
0
 
WebstormCommented:

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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
CEHJCommented:
What is the very next thing that comes after those lines darrellread?
0
 
darrellreadAuthor Commented:
Stupid Me, Excellent thanks for your help. Very Quick Response.
0
 
WebstormCommented:
:-)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now