-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formulario28.java
51 lines (42 loc) · 1.26 KB
/
Formulario28.java
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
51
import javax.swing.*;
import java.awt.event.*;
public class Formulario28 extends JFrame implements ActionListener{
private JLabel label1;
private JButton boton1, boton2, boton3;
public Formulario28(){
setLayout(null);
boton1= new JButton("1");
boton1.setBounds(10,100,90,30);
add(boton1);
boton1.addActionListener(this);
boton2= new JButton("2");
boton2.setBounds(110,100,90,30);
add(boton2);
boton2.addActionListener(this);
boton3= new JButton("3");
boton3.setBounds(210,100,90,30);
add(boton3);
boton3.addActionListener(this);
label1 = new JLabel("En espera...");
label1.setBounds(10,10,300,30);
add(label1);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == boton1){
label1.setText("Has presionado el botón 1");
}
if(e.getSource() == boton2){
label1.setText("Has presionado el botón 2");
}
if(e.getSource() == boton3){
label1.setText("Has presionado el botón 3");
}
}
public static void main (String args[]){
Formulario28 formulario1 = new Formulario28();
formulario1.setBounds(0,0,350,200);
formulario1.setVisible(true);
formulario1.setLocationRelativeTo(null);
formulario1.setResizable(false);
}
}