473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Code explanation(Java Swing programme using MouseListeners)

gautamz07
Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.swing.JFrame;
  4.  
  5. public class DisplayMouseCoordinates extends JFrame implements MouseMotionListener 
  6. {
  7. JLabel displayCoords;
  8.  
  9. public DisplayMouseCoordinates()
  10. {
  11. Container cp=getContentPane();
  12. JPanel panel=new JPanel();
  13. displayCords=new JLabel();
  14. panel.add(BorderLayout.CENTRE, displaycoords);
  15. cp.add(panel);
  16. setVisible(true);
  17. setSize(500,500);
  18. setTitle("Demo of mouse co-ordinates");
  19. panel.addMouseMotionListener(this);
  20. setLocationRelativeTo(null);
  21. }
  22. public static void main(String args[])
  23. {
  24. DisplayMouseCoordinates cords=new DisplayMouseCoordinates();
  25.  
  26. }
  27. public void MouseDragged(MouseEvent args0)
  28. {
  29. public void MouseMoved(MouseEvent Me)
  30. {
  31. String data= "(x: "+me.getx() + "," + "y:" + me.gety() + ")";
  32.  
  33. displayCords.setText("co-ordinates:" + data);
  34. }
  35. }
  36.  



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 .
Nov 17 '13 #1

✓ answered by r035198x

It's just creating a string by concatenating strings with other values.

1 1424
r035198x
13,262 8TB
It's just creating a string by concatenating strings with other values.
Nov 18 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Slimo | last post by:
Hello, Can someone post a sample code for ASP.NET using WMI (retrieve harddisk space, network card name,...) no matters I just need an example to see how it works. I prefer code using VB. Thanks
0
by: carmel stanley | last post by:
Hi i have been making an interactive programme,i have recently tried using "pyTTS" with it. This is a small ammount of it. import pyTTS tts = pyTTS.Create() tts.Rate = -3 tts.Speak('hi...
21
by: sirimanna | last post by:
hello, is any one can tell me how to create a small artificial intelligent programme using vb06. Can i creatre a artificial intelligent programme using vb6. is that vb06 support to creat a...
1
by: srivatsa86 | last post by:
HI i am doing a project of voice recognition.can anyone give me an c code for voice recording using microphone.. thanks a lot
1
by: lionkng | last post by:
I need a simple code for finding roots in c programme using Newton-raphson method
2
by: Selva123 | last post by:
Hi All, Greetings. I want to test JAVA SWING application with PERL, do we have any module to do so (like win32::GUI for windows)?. or some third party free tools integrated with PERL? I am...
1
by: Ben Stone | last post by:
I am trying to write C code for sin(x) using the first 5 terms of the taylor series. I am new to programming and am not allowed to use loops. I don't have much yet, but what I have so far is: /*...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.