Creating new Objects in loop - Java

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

  1. Arans

    Arans

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

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,620
    nemrac98@gmail.com
    Nov 4, 2005
  2. acamposr@gmail.com

    Creating new remote objects with RMI

    acamposr@gmail.com, Apr 25, 2006, in forum: Java
    Replies:
    11
    Views:
    2,549
  3. 7stud
    Replies:
    11
    Views:
    1,062
    Dennis Lee Bieber
    Mar 20, 2007
  4. Fish
    Replies:
    3
    Views:
    1,818
    D'Arcy J.M. Cain
    Mar 31, 2008
  5. News123
    Replies:
    7
    Views:
    563
    Dave Angel
    Jun 29, 2009
  6. Steve Drach
    Replies:
    3
    Views:
    444
    Thomas E Enebo
    Jun 20, 2004
  7. weblinkunlimited@gmail.com

    Javascript new-new-new-new-newbee

    weblinkunlimited@gmail.com, Mar 10, 2008, in forum: Javascript
    Replies:
    2
    Views:
    786
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
  8. Isaac Won
    Replies:
    9
    Views:
    784
    Ulrich Eckhardt
    Mar 4, 2013
Loading...