Creating new Objects in loop - Java

Discussion in 'Java' started by Arans, Dec 14, 2011.

  1. Arans

    Arans

    Joined:
    Dec 14, 2011
    Messages:
    1
    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 :)
     
    Arans, Dec 14, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nemrac98@gmail.com

    Creating new objects in for loop

    nemrac98@gmail.com, Nov 4, 2005, in forum: Java
    Replies:
    7
    Views:
    18,283
    nemrac98@gmail.com
    Nov 4, 2005
  2. 7stud
    Replies:
    11
    Views:
    750
    Dennis Lee Bieber
    Mar 20, 2007
  3. Fish
    Replies:
    3
    Views:
    1,437
    D'Arcy J.M. Cain
    Mar 31, 2008
  4. Steve Drach
    Replies:
    3
    Views:
    229
    Thomas E Enebo
    Jun 20, 2004
  5. Isaac Won
    Replies:
    9
    Views:
    451
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page