Programlama | Programlama Dilleri | C Programlama Dili |C++

Hata
  • XML Parsing Error at 1:82. Error 9: Invalid character


Mouse ile Elips Çiz ve Mouse Olaylar?

Netbeans platformunda yap?lan proje sayesinde ekran üzerinde mouse ile belirtilen k?s?mda elips çizilmesi sa?lamaktad?r. Dist klasorü içindeki "JavaApplication4.jar" uzant?l? dosya çal??t?r?larak sistem ba??ms?z program çal??t?r?labilir.

Program ile birlikte Mouse yard?m?yla elips çizilmesi sa?lan?r. Bu k?s?mda Mouse olaylar?na de?inilmi?tir.

Program?n Tamam?n? A?a??daki Linkten ?ndirebilirsiniz

Linki Görebilmeniz ?çin Üye Olman?z Gerekmektedir...

Üye Kay?t

Program Kodu:

  1.  
  2.  
  3. /*
  4.  * To change this template, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7.  
  8. package javaapplication4;
  9.  
  10. import java.awt.Color;
  11. import java.awt.Container;
  12. import java.awt.Dimension;
  13. import java.awt.FlowLayout;
  14. import java.awt.Graphics;
  15. import java.awt.event.MouseAdapter;
  16. import java.awt.event.MouseEvent;
  17. import java.awt.event.MouseMotionAdapter;
  18. import java.awt.event.MouseMotionListener;
  19. import javax.swing.JFrame;
  20. import javax.swing.JPanel;
  21.  
  22. /**
  23.  *
  24.  * @author Celal Atalar
  25.  */
  26.  
  27.  
  28.  
  29.  
  30. class PanelCan extends JPanel
  31. {
  32.  private int x1,x2,y1,y2;
  33.     public  PanelCan()
  34.     {
  35.        
  36.    
  37.     addMouseListener(
  38.            new MouseAdapter()
  39.     {
  40.       public void mousePressed (MouseEvent event) 
  41.       {
  42.        x1=event.getX();
  43.        y1=event.getY();
  44.       }
  45.       public void mouseReleased(MouseEvent event)
  46.       {
  47.        x2=event.getX();
  48.        y2=event.getY();
  49.        repaint();
  50.       }
  51.     }
  52.             );
  53.     
  54.     addMouseMotionListener(
  55.           new MouseMotionAdapter()
  56.     {
  57.       public void MouseDragged(MouseEvent event)
  58.       {
  59.        x2=event.getX();
  60.        y2=event.getY();
  61.        repaint();
  62.       }       
  63.     }
  64.     );
  65.     }
  66.    public void paintComponent(Graphics g)
  67.     {
  68.      super.paintComponent(g);
  69.      g.drawOval(Math.min(x1, x2),Math.min(y1, y2),Math.abs(x1-x2),Math.abs(y1-y2));  
  70.     }
  71.    public  Dimension getPreferredSize()
  72.    {
  73.      return new Dimension(200,150);
  74.    }       
  75.   
  76.  
  77. }
  78. public class ElipsCiz extends JFrame
  79. {
  80.     private int x1,x2,y1,y2;
  81.     public ElipsCiz()
  82.     {
  83.    
  84.     PanelCan benimpanel=new PanelCan();
  85.     Container pencere=getContentPane();
  86.     pencere.setLayout(new FlowLayout());
  87.     pencere.add(benimpanel);
  88.     benimpanel.setBackground(Color.green);
  89.     addMouseMotionListener(
  90.        
  91.             new MouseMotionAdapter()
  92.     {
  93.     public void MouseDragged(MouseEvent event)
  94.     {
  95.        setTitle("Sürükleniyor->Mouse Koordinatlar?: X:"+event.getX()+", Y:"+event.getY());
  96.     }
  97.      public void MouseMoved(MouseEvent event)
  98.     {
  99.        setTitle("Hareket Ediyor->Mouse Koordinatlar?: X:"+event.getX()+", Y:"+event.getY());
  100.     }
  101.     }
  102.            
  103.            
  104.     );
  105.     setSize(400,200);
  106.     setVisible(true);
  107.     }
  108.    
  109.     public static void main(String args[])
  110.     {
  111.     ElipsCiz program=new ElipsCiz();
  112.     program.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  113.     }       
  114. }
  115.  

Yorumlar (0)
Sadece kayıtlı kullanıcılar yorum yazabilir!
Son Güncelleme ( Salı, 14 Haziran 2011 10:41 )  
404 Not Found

404

Not Found

The resource requested could not be found on this server!


Proudly powered by LiteSpeed Web Server

Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.