Creating new Objects in loop - Java

Joined
Dec 14, 2011
Messages
1
Reaction score
0
Hi All,

Possibly this is a repeat thread, but help on this.

I need to create new instance of JRadioButton within loop uniquly which I can refer in a program.

Here's the snapshot

JRadioButton className1 = new JRadioButton("test1");
className.setMnemonic(KeyEvent.VK_A);
className.setActionCommand("test1");
className.setSelected(true);

JRadioButton className2 = new JRadioButton("test2");
className.setMnemonic(KeyEvent.VK_B);
className.setActionCommand("test2");
className.setSelected(true);

JRadioButton className3 = new JRadioButton("test3");
className.setMnemonic(KeyEvent.VK_C);
className.setActionCommand("test3");
className.setSelected(true);

the object should be instantiated dynamically with the values retrieved from loop and this dynamic object, I should be able to use it anywhere in the program for further use.

Any help will be appreciated, Thanks in advance :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top