Code:
import java.awt.*; import javax.swing.*; import java.swing.JFrame; public class DisplayMouseCoordinates extends JFrame implements MouseMotionListener { JLabel displayCoords; public DisplayMouseCoordinates() { Container cp=getContentPane(); JPanel panel=new JPanel(); displayCords=new JLabel(); panel.add(BorderLayout.CENTRE, displaycoords); cp.add(panel); setVisible(true); setSize(500,500); setTitle("Demo of mouse co-ordinates"); panel.addMouseMotionListener(this); setLocationRelativeTo(null); } public static void main(String args[]) { DisplayMouseCoordinates cords=new DisplayMouseCoordinates(); } public void MouseDragged(MouseEvent args0) { public void MouseMoved(MouseEvent Me) { String data= "(x: "+me.getx() + "," + "y:" + me.gety() + ")"; displayCords.setText("co-ordinates:" + data); } }
String data= "(x: "+me.getx() + "," + "y:" + me.gety() + ")";
What Does This Line really Do in the Code . please do explain the syntex as i have never seen something like this in java and i'am new to swing .
Comment