• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JRadioButton Help!

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a database in my program and I want to be able to create a radio button which is named after a column name- obviously I can't specify the name of the column myself because the number of column may change for each database as well as the names for them. I have tried the following but get an error indicating that the left hand side must be a variable name. How should I do it?
for(int i=0; i<rsmd.getColumnCount(); i++){JRadioButton (rsmd.getColumnName(i))= new JRadioButton("" +rsmd.getColumnName(i)+ "");}
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, big error.
Your JRadioButton variable name needs to be a valid variable name, aka a regular string: myRadioButton, something like that. If you want a mapping from column names to its corresponding JRadioButton, try a Hashtable, where each key is the column name, and the value is the JRadioButton:

Well, you get the idea.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic