import java.awt.Container;
import java.awt.Font;
import java.awt.event.*;
import javax.swing.*;
public class Despachadora2 extends JFrame{
Hilo1 agua=new Hilo1();
Hilo2 hielo=new Hilo2();
HiloT1 tiempo1=new HiloT1();
HiloT2 tiempo2=new HiloT2();
Hilo h=new Hilo();
HiloH h2=new HiloH();
JLabel lblTexto=new JLabel("Despachadora de Agua/Hielo");
ImageIcon im1=new ImageIcon("refrigerador.jpg");
ImageIcon im0=new ImageIcon("refrigerador2.jpg");
ImageIcon im2=new ImageIcon("Vaso.jpg");
ImageIcon im3=new ImageIcon("Hielo.jpg");
ImageIcon im4=new ImageIcon("Agua.jpg");
JLabel lblImagen2=new JLabel(im0);
JLabel lblImagen=new JLabel(im1);
JLabel lblVaso=new JLabel(im2);
JLabel lblHielo=new JLabel(im3);
JLabel lblAgua=new JLabel(im4);
JButton btnAgua=new JButton("Agua");
JButton btnHielo=new JButton("Hielo");
JButton btn1=new JButton("$5 Chico");
JButton btn2=new JButton("$8 Mediano");
JButton btn5=new JButton("$12 Grande");
JLabel lblTex=new JLabel("Tu cambio es: $");
JLabel lblCambio=new JLabel();
JLabel lblDinero=new JLabel("Introduce tu dinero: $");
JTextField txtDinero=new JTextField();
public boolean issuspended = false;
JPanel panel=new JPanel();
int posx, posy;
Despachadora2(String Cambio){
setTitle("Despachadora de Hielo y Agua");
setSize(415,625);
tiempo1.start();
tiempo2.start();
panel.setLayout(null);
lblCambio.setText(Cambio);
lblDinero.setFont(new Font("Arial", Font.BOLD, 15));
lblDinero.setBounds(200,10,160,50);
panel.add(lblDinero);
txtDinero.setBounds(355,25,30,20);
panel.add(txtDinero);
lblTex.setFont(new Font("Arial", Font.BOLD,15));
lblTex.setBounds(10,10,110,50);
panel.add(lblTex);
lblTex.setFont(new Font("Arial", Font.BOLD,15));
lblCambio.setBounds(130,10,100,50);
panel.add(lblCambio);
btnAgua.setBounds(60,185,70,20);
panel.add(btnAgua);
btnHielo.setBounds(280,185,70,20);
panel.add(btnHielo);
btn1.setBounds(40,70,90,20);
panel.add(btn1);
btn2.setBounds(150,70,100,20);
panel.add(btn2);
btn5.setBounds(270,70,100,20);
panel.add(btn5);
lblVaso.setBounds(160,290,100,150);
panel.add(lblVaso);
lblImagen2.setBounds(160,152,100,100);
panel.add(lblImagen2);
lblHielo.setBounds(160,152,100,100);
panel.add(lblHielo);
lblAgua.setBounds(160,152,100,100);
panel.add(lblAgua);
lblImagen.setBounds(0,0,415,625);
panel.add(lblImagen);
Container c=getContentPane();
c.add(panel);
btnHielo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent h){
hielo.start();
h2.start();
}
});
btnAgua.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent a){
agua.start();
h.start();
}
});
btn1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent uno){
btn1.setEnabled(false);
}
});
btn2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent dos){
btn2.setEnabled(false);
}
});
btn5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent cinco){
btn5.setEnabled(false);
}
});
}
class Hilo extends Thread{
public void run(){
try{
Thread.sleep(4000);
dispose();
new Despachadora3().setVisible(true);
}catch(Exception er){}
}
}
class HiloH extends Thread{
public void run(){
try{
Thread.sleep(4000);
dispose();
new Despachadora3().setVisible(true);
}catch(Exception er){}
}
}
class Hilo1 extends Thread{
public void run(){
int y=200;
try{
while(true){
Thread.sleep(100);
lblAgua.setBounds(160,y,100,100);
y=y+20;
if(y>250){
y=220;
}
}
}catch(Exception er){}
}
}
class Hilo2 extends Thread{
public void run(){
int y=152;
try{
while(true){
Thread.sleep(200);
lblHielo.setBounds(160,y,100,100);
y=y+20;
if(y>290){
y=220;
}
}
}catch(Exception er){}
}
}
class HiloT1 extends Thread{
public void run(){
try{
Thread.sleep(1000);
//new Despachadora3().setVisible(true);
}catch(Exception er){}
}
}
class HiloT2 extends Thread{
public void run(){
try{
Thread.sleep(1000);
}catch(Exception er){}
}
}
}
No hay comentarios:
Publicar un comentario