Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

<identifier> expected problem  with ButtonGroup

Thread view: 
learningjava - 15 Dec 2003 16:04 GMT
Here is a snippet of code  (not complete, but to show the problem I
get)

I'm trying to add 2 radio buttons b1 and b2 to a group bg.
But the compiler always complains of an "<identifier> expected " .
I think I'm not doing anything wrong here, this is pretty
straightforward code.
However, my cheers to anyone who can point me to what's wrong and how
to get ir right!


code:
**
import javax.swing.*;
public class BG {

JRadioButton b1 = new JRadioButton( "first button" );
JRadioButton b2 = new JRadioButton( "second button" );

ButtonGroup bg = new ButtonGroup();
bg.add( b1 );
bg.add( b2 );
}

**

Thanks,

gklinux
Andrew Thompson - 15 Dec 2003 16:41 GMT
> Here is a snippet of code  (not complete, but to show the problem I
> get)
....
> code:
> **
[quoted text clipped - 5 lines]
>
> ButtonGroup bg = new ButtonGroup();

BG()
{

> bg.add( b1 );
> bg.add( b2 );

}

> }
>
> **
Thomas Fritsch - 15 Dec 2003 17:08 GMT
learningjava schrieb:

>Here is a snippet of code  (not complete, but to show the problem I
>get)
>
>I'm trying to add 2 radio buttons b1 and b2 to a group bg.
>But the compiler always complains of an "<identifier> expected " .

Posting the exact compiler error messages would have been very nice.
(Please remember next time!)
BG.java:8: <identifier> expected
bg.add( b1 );
     ^
BG.java:9: <identifier> expected
bg.add( b2 );
     ^

>I think I'm not doing anything wrong here, this is pretty
>straightforward code.
[quoted text clipped - 10 lines]
>
>ButtonGroup bg = new ButtonGroup();

public BG()    // Constructor
{

>bg.add( b1 );
>bg.add( b2 );

   // The 2 lines above don't make sense outside any method or constructor.
}

>}
>
[quoted text clipped - 3 lines]
>
>gklinux


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.