| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,46 @@ | |||
| 1 | + package com.applikdos; | ||
| 2 | + | ||
| 3 | + import java.awt.event.ActionEvent; | ||
| 4 | + import java.awt.event.ActionListener; | ||
| 5 | + | ||
| 6 | + import javax.swing.*; | ||
| 7 | + | ||
| 8 | + public class FormularioEventos extends JFrame implements ActionListener { | ||
| 9 | + | ||
| 10 | + JButton boton1, boton2; | ||
| 11 | + | ||
| 12 | + public static void main(String[] args) { | ||
| 13 | + new FormularioEventos(); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + public FormularioEventos() { | ||
| 17 | + setTitle("Formulario"); | ||
| 18 | + setSize(550, 250); | ||
| 19 | + setLayout(null); | ||
| 20 | + setVisible(true); | ||
| 21 | + | ||
| 22 | + boton1 = new JButton(); | ||
| 23 | + boton1.setText("Aceptar"); | ||
| 24 | + boton1.setBounds(150, 100, 100, 30); | ||
| 25 | + getContentPane().add(boton1); | ||
| 26 | + boton1.addActionListener(this); | ||
| 27 | + | ||
| 28 | + boton2 = new JButton(); | ||
| 29 | + boton2.setText("Cerrar"); | ||
| 30 | + boton2.setBounds(260, 100, 100, 30); | ||
| 31 | + getContentPane().add(boton2); | ||
| 32 | + boton2.addActionListener(this); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void actionPerformed(ActionEvent evento){ | ||
| 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments