View difference between Paste ID: 8q77pyux and UbPdnpys
SHOW: | | - or go back to the newest paste.
1
package tabella;
2
3
import javax.swing.*;
4
import java.awt.*;
5
6
public class Tabella implements java.awt.event.ActionListener {
7
	
8
	public static void main (String args[]) {
9
		createAndShowGUI();
10
	}
11
	
12
        @Override
13
        public void actionPerformed(java.awt.event.ActionEvent evt) {
14
            javax.swing.JOptionPane.showMessageDialog(null, evt.getActionCommand(), "Evento", JOptionPane.OK_OPTION);
15
        }
16
        
17
	private static void createAndShowGUI() {
18
		
19
		JFrame frame = new JFrame("Grid");
20
		frame.setLayout(new GridLayout(8,4));
21
		JButton[] buttons = new JButton[61];
22
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
23
                
24
                for(int i=0; i <= 60; ++i) {
25-
                    buttons[i] = new JButton(""+i);
25+
                    buttons[i] = new JButton(Integer.toString(i));
26
                    frame.add(buttons[i]);
27
                    buttons[i].addActionListener(new Tabella());
28
                 }
29
                
30
		frame.pack();
31
		frame.setVisible(true);
32
		
33
    }
34
35
36
}