| Author |
dynamic array of JRadioButton in Jscrollpane
|
Ankit Kr Sah
Greenhorn
Joined: Feb 19, 2013
Posts: 4
|
|
|
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
Ranch Hand
Joined: Sep 13, 2007
Posts: 1222
|
|
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 JavaRanch SCJP5 SCJD/OCM-JD
|
 |
K. Tsang
Ranch Hand
Joined: Sep 13, 2007
Posts: 1222
|
|
|
And Welcome to the Ranch
|
 |
Ankit Kr Sah
Greenhorn
Joined: Feb 19, 2013
Posts: 4
|
|
|
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
Ranch Hand
Joined: Sep 13, 2007
Posts: 1222
|
|
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
Joined: Feb 19, 2013
Posts: 4
|
|
|
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
Ranch Hand
Joined: Sep 13, 2007
Posts: 1222
|
|
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.
|
 |
 |
|
|
subject: dynamic array of JRadioButton in Jscrollpane
|
|
|