Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 05-22-2013, 04:33 AM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › Java v
« Previous 1 ... 3 4 5 6 7 8 Next »

Mouse = Tikus :D

Home General Computer Multimedia Business Lounge

Post Reply 
Tweet
Threaded Mode | Linear Mode
Mouse = Tikus :D
03-27-2012, 04:33 AM (This post was last modified: 03-28-2012 04:19 AM by Si Cupu.)
Post: #1
Si Cupu Away
./Devilz Officer
Posts: 106
Joined: Dec 2010
Reputation: 7
Mouse = Tikus :D
Misi om DC
Cuma mau ngshare codingan cupu dari ane yang cupunya setengah mampus belajar

disini ane cuma buat codingan untuk mengetahui posisi mouse px

save filenya dengan mouse.java

bila TS ane kurang bermanfaat di apus aja min prustasi

Code:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Mouse extends JFrame
{
    private JLabel statusbar;
    private JPanel mousePanel;

    public Mouse()
    {
        super( "Mouse Event" );

        mousePanel = new JPanel();
        mousePanel.setBackground( Color.WHITE );
        add( mousePanel, BorderLayout.CENTER );

        statusbar = new JLabel( "Mouse outside JPanel" );
        add( statusbar, BorderLayout.SOUTH );

        MHandler handler = new MHandler();
        mousePanel.addMouseListener( handler );
        mousePanel.addMouseMotionListener( handler );

        setDefaultCloseOperation( EXIT_ON_CLOSE );
        setSize( 300, 300 );
        setVisible( true );
    }

    private class MHandler implements MouseListener, MouseMotionListener
    {
        public void mouseClicked( MouseEvent e )
        {
            statusbar.setText( String.format( "Clicked at [%d, %d]", e.getX(), e.getY() ) );
        }

        public void mousePressed( MouseEvent e )
        {
            statusbar.setText( String.format( "Pressed at [%d, %d]", e.getX(), e.getY() ) );
        }

        public void mouseReleased( MouseEvent e )
        {
            statusbar.setText( String.format( "Released at [%d, %d]", e.getX(), e.getY() ) );
        }

        public void mouseEntered( MouseEvent e )
        {
            statusbar.setText( String.format( "Mouse entered at [%d, %d]", e.getX(), e.getY() ) );
            mousePanel.setBackground( Color.GREEN );
        }

        public void mouseExited( MouseEvent e )
        {
            statusbar.setText( String.format( "Mouse exited at [%d, %d]", e.getX(), e.getY() ) );
            mousePanel.setBackground( Color.WHITE );
        }

        public void mouseDragged( MouseEvent e )
        {
            statusbar.setText( String.format( "Dragged at [%d, %d]", e.getX(), e.getY() ) );
        }

        public void mouseMoved( MouseEvent e )
        {
            statusbar.setText( String.format( "Moved at [%d, %d]", e.getX(), e.getY() ) );
        }

    }

    public static void main( String args[] )
    {
        new Mouse();
    }
}

Haturnuhun, maap klo msh banyak kesalahan belajar
Find all posts by this user
Quote this message in a reply
 Reputed by :  tabun(+1) , ./ rex(+1)
03-27-2012, 08:14 AM
Post: #2
fuxnbums Offline
Orang Ganteng Stok Pertama
*****
DeMT Team
Posts: 732
Joined: Jun 2011
Reputation: 33
RE: Mouse = Tikus :D
btw pungsinya wat apa om ? ketawa
Visit this user's website Find all posts by this user
Quote this message in a reply
03-27-2012, 10:11 AM
Post: #3
hakimoxz Offline
./Devilz Advisor
Posts: 775
Joined: Jul 2011
Reputation: 37
RE: Mouse = Tikus :D
mantep om cupu nih untuk mengetahui posisi mouse px
[Image: di-8S8A.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
03-27-2012, 01:25 PM
Post: #4
sunafets.exe Offline
./Devilz Commander
Posts: 297
Joined: Aug 2011
Reputation: 4
RE: Mouse = Tikus :D
save-nya dengan format apa kaka ?
Find all posts by this user
Quote this message in a reply
03-27-2012, 01:36 PM
Post: #5
DevilzLaugh Offline
./DevilzLaugh
Posts: 122
Joined: Feb 2012
RE: Mouse = Tikus :D
Tuh buat paan seh?
Visit this user's website Find all posts by this user
Quote this message in a reply
03-27-2012, 03:12 PM
Post: #6
DC_Julianz Offline
Null
**
Moderators
Posts: 2,013
Joined: Sep 2011
Reputation: 70
RE: Mouse = Tikus :D
belajar bisa lebih details omz aku bingung sumpah pusing
Visit this user's website Find all posts by this user
Quote this message in a reply
03-28-2012, 03:03 AM
Post: #7
noe Away
./Devilz Officer
Posts: 223
Joined: May 2011
Reputation: 9
RE: Mouse = Tikus :D
bingung aku ih kaget
Visit this user's website Find all posts by this user
Quote this message in a reply
03-28-2012, 12:45 PM
Post: #8
cliquersz Away
./Devilz Officer
Posts: 235
Joined: Jan 2012
Reputation: 9
RE: Mouse = Tikus :D
fungsinya untuk apa sob ?
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-22-2013, 04:33 AM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE