Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

In this page you can find the example usage for java.awt Point Point.

Prototype

public Point() 

Source Link

Document

Constructs and initializes a point at the origin (0, 0) of the coordinate space.

Usage

From source file:Main.java

public static void main(String[] args) {
    Point p = new Point();
    System.out.println(p.toString());
}

From source file:Main.java

public static void main(String[] args) {
    Point p = new Point();

    p.setLocation(2.3D, 3.3D);
    System.out.println(p.toString());
}

From source file:Main.java

public static void main(String[] args) {
    Point p = new Point();

    p.setLocation(2.3D, 3.3D);// www.java 2  s .c  o m
    System.out.println(p.getLocation());
}

From source file:Main.java

public static void main(String[] args) {
    Point p = new Point();

    p.setLocation(new Point(2, 3));
    System.out.println(p.toString());
}

From source file:Main.java

public static void main(String[] args) {
    Point p = new Point();

    p.setLocation(2, 3);
    System.out.println(p.toString());
}

From source file:Main.java

public static void main(String[] args) {
    Point p = new Point();

    p.setLocation(2.3D, 3.3D);/*  w  w w . ja  va2s . com*/
    System.out.println(p.getX());
    System.out.println(p.getY());
}

From source file:MainClass.java

public static void main(String[] args) {
    Point aPoint = new Point(); // Initialize to 0,0
    Point bPoint = new Point(50, 25);
    Point cPoint = new Point(bPoint);
    System.out.println("aPoint is located at: " + aPoint);
    aPoint.move(100, 50); // Change to position 100,50
    bPoint.x = 110;/*ww w  .  j ava2 s  .  co m*/
    bPoint.y = 70;
    aPoint.translate(10, 20); // Move by 10 in x and 20 in y
    System.out.println("aPoint is now at: " + aPoint);
    if (aPoint.equals(bPoint))
        System.out.println("aPoint and bPoint are at the same location.");
}

From source file:Main.java

public static void main(String[] args) {
    Point aPoint = new Point();
    Point bPoint = new Point(50, 25);
    Point cPoint = new Point(bPoint);

    System.out.println("cPoint is located at: " + cPoint);

    System.out.println("aPoint is located at: " + aPoint);
    aPoint.move(100, 50);//from w  w w  .j  a v a2 s.c  om

    bPoint.x = 110;
    bPoint.y = 70;

    aPoint.translate(10, 20);
    System.out.println("aPoint is now at: " + aPoint);

    if (aPoint.equals(bPoint))
        System.out.println("aPoint and bPoint are at the same location.");
}

From source file:Main.java

/**
 * Returns the screen location for a component and X and Y.
 *///from   w ww.  j  av  a  2  s.  c  o m
private static Point getScreenLocation(Component aComp, int anX, int aY) {
    Point point = aComp != null && aComp.isShowing() ? aComp.getLocationOnScreen() : new Point();
    point.x += anX;
    point.y += aY;
    return point;
}

From source file:Main.java

public static void setScreenCenter(Container container) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenDimension = toolkit.getScreenSize();
    int width = container.getWidth();
    int height = container.getHeight();
    Point point = new Point();
    point.setLocation((screenDimension.getWidth() - width) / 2, (screenDimension.getHeight() - height) / 2);
    container.setLocation(point);/*from w  ww  .j ava 2  s .c o  m*/
}