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

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...