Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JRadioButton Help!  RSS feed

 
Naf Rash
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • 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)+ "");}
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!