Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tabella;
- import javax.swing.*;
- import java.awt.*;
- public class Tabella implements java.awt.event.ActionListener {
- public static void main (String args[]) {
- createAndShowGUI();
- }
- @Override
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- javax.swing.JOptionPane.showMessageDialog(null, evt.getActionCommand(), "Evento", JOptionPane.OK_OPTION);
- }
- private static void createAndShowGUI() {
- JFrame frame = new JFrame("Grid");
- frame.setLayout(new GridLayout(8,4));
- JButton[] buttons = new JButton[61];
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- for(int i=0; i <= 60; ++i) {
- buttons[i] = new JButton(Integer.toString(i));
- frame.add(buttons[i]);
- buttons[i].addActionListener(new Tabella());
- }
- frame.pack();
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement