How to get pos X and Y of object in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to get pos X and Y of object in java

Hello! I have the problem. How to get the position X and Y for button or something and how to change it. I was started with Java swing and I created the simple clicker. Thanks!

28th Apr 2020, 7:52 PM
Grzesiek Sikorski
Grzesiek Sikorski - avatar
2 Answers
+ 1
Hello Grzesiek JButton has a getX() and a getY() method. Here is a tutorial how to set the location of a Button: https://www.tutorialspoint.com/how-to-set-the-location-of-a-button-anywhere-in-jframe
28th Apr 2020, 8:37 PM
Denise Roßberg
Denise Roßberg - avatar
0
Thanks it helped me ;)
29th Apr 2020, 6:06 AM
Grzesiek Sikorski
Grzesiek Sikorski - avatar