Taller parcial

166 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
166
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Taller parcial

  1. 1. import javax.swing.*;import java.awt.event.*;public class Taller_Parcial extends JFrame implements ActionListener {private JButton boton1,boton2;private JTextField campoTexto,campoTexto2;public Taller_Parcial() {super("Primero Y Segundo Punto :");setLayout(null);//Di HOLAboton1=new JButton("Di Hola");boton1.setBounds(50,50,90,30);add(boton1);boton1.addActionListener(this);campoTexto = new JTextField( 40 );campoTexto.setBounds(200,50,150,30);campoTexto.setEditable( false );campoTexto.setVisible(false);add( campoTexto );//Di Adiosboton2=new JButton("Di Adios");boton2.setBounds(50,100,90,30);add(boton2);
  2. 2. boton2.addActionListener(this);setResizable(false);campoTexto2 = new JTextField( 40);campoTexto2.setBounds(200,100,150,30);campoTexto2.setEditable( false );campoTexto2.setVisible(false);add( campoTexto2 );}//Contadorint contador1=0,contador2=0;public void actionPerformed(ActionEvent e) {if (e.getSource()==boton1) {campoTexto.setText("Veces Oprimido : "+(contador1+1));campoTexto.setVisible(true);contador1++;}if(e.getSource()==boton2){campoTexto2.setText("Veces Oprimido : "+(contador2+1));campoTexto2.setVisible(true);contador2++;}}
  3. 3. public static void main(String[] args) {Taller_Parcial ventana=new Taller_Parcial();ventana.setBounds(0,0,400,200);ventana.setVisible(true);ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}

×