Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic array of JRadioButton in Jscrollpane

 
Ankit Kr Sah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to populate a scrollpane with radio button in it,,assuming the no of radio button is n, please help i m stuck
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Place those radio buttons in a JPanel then put the JPanel in the JScrollPane.

Don't know what you mean by "dynamic", but if you are to say refresh/repaint this JPanel based on some action ... then you should use an ArrayList to hold your radio button.
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Welcome to the Ranch
 
Ankit Kr Sah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you tsang, in reference of dynamic ....i am fetching list of tables from database metadata but i dont know what will be the total number of tables so depending on that number i will create radio buttons
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Kr Sah wrote:thank you tsang, in reference of dynamic ....i am fetching list of tables from database metadata but i dont know what will be the total number of tables so depending on that number i will create radio buttons


Without knowing what you will do with such selection, I suggest you use a drop down menu for this list.
 
Ankit Kr Sah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also thought to implement dropdown but if total no of tables will be more than 200 then it will be tedious to select in dropdown
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Kr Sah wrote:I also thought to implement dropdown but if total no of tables will be more than 200 then it will be tedious to select in dropdown


Hmm not really. Given your original approach is radio button so the drop down menu is single selection.

It's really hard to say what component to use without knowing what you are doing exactly with the selected item (table).

If you worry about populating the drop down is tedious ... don't be. Just use the JComboBox(Object[]) constructor. Of course your object array can be converted from a list which get populate from the database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic