Is it possible to store array into object array?

ساخت وبلاگ

Vote count: 0

I have 30 JToggleButton. If they get pressed, I want to pass the i and the title into another class .

 confirm.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean buttonClicked = false; for (i = 0; i < 30; i++) { if (ButtonList[i].isSelected()) { buttonClicked = true; System.out.print(i+1); System.out.println(title); } } // System.out.println(title); if (!buttonClicked) { JFrame parent= new JFrame(); JOptionPane.showMessageDialog(parent, "You haven't select a seat"); } } });

The above code give me this output (Assume 2 toggle button clicked )

1Marvel's Captain America

2Marvel's Captain America

I only want title display once, so I decided to move

System.out.println(title); 

above code

if (!buttonClicked) {

My question is how can I store the array i into a object so that it can pass with the title in a new function called pass() ? The number of title printed seems following the total number of toggleButton clicked. How to avoid this ?

asked 6 mins ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 257 تاريخ : جمعه 31 ارديبهشت 1395 ساعت: 22:59