An object of the Point class represents a location in a two-dimensional space.
For example, we can set the location of a JButton using Point
.
JButton closeButton = new JButton("Close"); //The following two statements do the same thing. closeButton.setLocation(10, 15); closeButton.setLocation(new Point(10, 15)); // Get the location of the closeButton Point p = closeButton.getLocation();
import java.awt.Point; public class Main { public static void main(String[] args) { Point p = new Point(100,100); /*from w ww . java2s . co m*/ System.out.println(p.x); } }