Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f8cd57

Browse files
committed
Se agrego codigo fuente tutorial eventos en java
1 parent476820f commit1f8cd57

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
packagecom.applikdos;
2+
3+
importjava.awt.event.ActionEvent;
4+
importjava.awt.event.ActionListener;
5+
6+
importjavax.swing.*;
7+
8+
publicclassFormularioEventosextendsJFrameimplementsActionListener {
9+
10+
JButtonboton1,boton2;
11+
12+
publicstaticvoidmain(String[]args) {
13+
newFormularioEventos();
14+
}
15+
16+
publicFormularioEventos() {
17+
setTitle("Formulario");
18+
setSize(550,250);
19+
setLayout(null);
20+
setVisible(true);
21+
22+
boton1 =newJButton();
23+
boton1.setText("Aceptar");
24+
boton1.setBounds(150,100,100,30);
25+
getContentPane().add(boton1);
26+
boton1.addActionListener(this);
27+
28+
boton2 =newJButton();
29+
boton2.setText("Cerrar");
30+
boton2.setBounds(260,100,100,30);
31+
getContentPane().add(boton2);
32+
boton2.addActionListener(this);
33+
}
34+
35+
publicvoidactionPerformed(ActionEventevento){
36+
37+
if(evento.getSource()==boton1){
38+
JOptionPane.showMessageDialog(null,"Este es el boton 1");
39+
}
40+
41+
if(evento.getSource()==boton2){
42+
JOptionPane.showMessageDialog(null,"Este es el boton 2");
43+
}
44+
45+
}
46+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp