-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatriz.java
More file actions
50 lines (44 loc) · 1.36 KB
/
Matriz.java
File metadata and controls
50 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package interfacesgraficas;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.ArrayList;
public class Matriz extends JFrame implements ActionListener {
JFrame f;
JButton b, boton2;
ArrayList<JButton> botones = new ArrayList<>();
public int num = 0;
Matriz() {
b = new JButton("Crear Matriz");
b.setBounds(50, 50, 350, 100);
this.add(b);
this.setSize(450, 200);
this.setLayout(null);
this.setVisible(true);
b.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
int contador = 1;
if (e.getSource() == b) {
num += 1;
for(int i=0;i<90;i+=30) {
for(int j=0;j<450;j+=150) {
boton2 = new JButton();
boton2.setBounds(j, i, 150, 30);
boton2.setText(String.valueOf(contador));
this.add(boton2);
boton2.setVisible(true);
contador++;
boton2.addActionListener(this);
botones.add(boton2);
}
}
b.setBounds(130, 100, 130+num*5, 40+num*5);
}
repaint();
}
public static void main(String[] args) {
new Matriz();
}
}