Advertisement
Guest User

Java

a guest
Jun 30th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.69 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package Interface;
  7.  
  8. import java.awt.Point;
  9. import java.awt.event.MouseEvent;
  10. import java.awt.event.MouseListener;
  11. import javax.swing.JFrame;
  12.  
  13. /**
  14.  *
  15.  * @author Pessoal
  16.  */
  17. public class Interface extends JFrame implements MouseListener{
  18.     static Point p = new Point();
  19.     public static void main(String[] args) {
  20.         JFrame j = new JFrame("Interface");
  21.         InterfaceClasse ic = new InterfaceClasse();
  22.         j.add(ic);
  23.         j.setSize(1300, 768);
  24.         j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  25.         j.setVisible(true);
  26.         j.setResizable(false);
  27.        
  28.         ic.setTemperatura(30.0f);
  29.         ic.setTensao(24.0f);
  30.         ic.setVelocidade(10.0f);
  31.        
  32.     }
  33.     @Override
  34.     public void mouseClicked(MouseEvent e) {
  35.         InterfaceClasse ic = new InterfaceClasse();
  36.         p=getMousePosition();
  37.         if(p.x>=50 && p.x <=350 && p.y>=284 && p.y<=484){
  38.         ic.setTensao(20.0f);
  39.         ic.setTemperatura(25.5f);
  40.         ic.setVelocidade(3.5f);
  41.             System.out.println("Deu certo");
  42.         }
  43.         if(p.x>=950 && p.x <=1250 && p.y>=284 && p.y<=484){
  44.         ic.setTensao(27.0f);
  45.         ic.setTemperatura(33.5f);
  46.         ic.setVelocidade(14.0f);
  47.             System.out.println("Deu certo");
  48.         }
  49.         if(p.x>=500 && p.x <=800 && p.y>=50 && p.y<=250){
  50.         ic.setTensao(24.0f);
  51.         ic.setTemperatura(35.5f);
  52.         ic.setVelocidade(10.0f);
  53.             System.out.println("Deu certo");
  54.         }
  55.         if(p.x>=500 && p.x <=800 && p.y>=518 && p.y<=718){
  56.         ic.setTensao(17.0f);
  57.         ic.setTemperatura(17.3f);
  58.         ic.setVelocidade(2.0f);
  59.             System.out.println("Deu certo");
  60.         }
  61.     }
  62.  
  63.     @Override
  64.     public void mousePressed(MouseEvent e) {
  65.         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  66.     }
  67.  
  68.     @Override
  69.     public void mouseReleased(MouseEvent e) {
  70.         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  71.     }
  72.  
  73.     @Override
  74.     public void mouseEntered(MouseEvent e) {
  75.         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  76.     }
  77.  
  78.     @Override
  79.     public void mouseExited(MouseEvent e) {
  80.         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement