aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes dynamic array of JRadioButton in Jscrollpane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "dynamic array of JRadioButton in Jscrollpane" Watch "dynamic array of JRadioButton in Jscrollpane" New topic
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
Bartender

Joined: Sep 13, 2007
Posts: 2584
    
    9

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 OCPJP7 OCPWCD5 OCPBCD5
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2584
    
    9

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
Bartender

Joined: Sep 13, 2007
Posts: 2584
    
    9

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
Bartender

Joined: Sep 13, 2007
Posts: 2584
    
    9

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic array of JRadioButton in Jscrollpane