Whats wrong with my ButtonGroup? Compiler error

RoarG

As the topic says, I am having issues with this snippet of code. On last line I get both;

  • Syntax error on token(s), misplaced construct(s)

  • Syntax error on token UpperCaseButton, VariableDeclaratorId expected after this token:


static JToggleButton UpperCaseButton = new JToggleButton("Upper Case");
static JToggleButton LowerCaseButton = new JToggleButton("Lower Case");

//ButtonGroup for the Toggelbuttons
ButtonGroup group = new ButtonGroup();
group.add(UpperCaseButton);

I am a bit confused here, so please help.

RainMaker
group.add(UpperCaseButton);

The above piece of code should be present inside a method and not just hang around in the class. Since all the other statements are just declarations, it is allowed to be present in the class but the same isn't allowed for group.add(UpperCaseButton); in Java.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related