Tabnine Logo
Point
Code IndexAdd Tabnine to your IDE (free)

How to use
Point
in
java.awt

Best Java code snippets using java.awt.Point (Showing top 20 results out of 7,803)

Refine searchRefine arrow

  • Window
  • Container
  • JFrame
  • Component
  • Display
  • Rectangle
  • JComponent
origin: runelite/runelite

final Point topLeftPoint = new Point(
  viewportOffset + BORDER,
  viewportOffset + BORDER_TOP);
final Point topCenterPoint = new Point(
  viewportOffset + viewportBounds.width / 2,
  viewportOffset + BORDER
);
final Point topRightPoint = new Point(
  viewportOffset + viewportBounds.width - BORDER,
  topCenterPoint.y);
final Point bottomLeftPoint = new Point(
  topLeftPoint.x,
  viewportOffset + viewportBounds.height - BORDER);
final Point bottomRightPoint = new Point(
  topRightPoint.x,
  bottomLeftPoint.y);
final Point rightChatboxPoint = isResizeable ? new Point(
  viewportOffset + chatboxBounds.width - BORDER,
  bottomLeftPoint.y) : bottomRightPoint;
final Point canvasTopRightPoint = isResizeable ? new Point(
  (int)client.getRealDimensions().getWidth(),
  0) : topRightPoint;
origin: stackoverflow.com

 * Fetches angle relative to screen centre point
 * where 3 O'Clock is 0 and 12 O'Clock is 270 degrees
 * 
 * @param screenPoint
 * @return angle in degress from 0-360.
 */
public double getAngle(Point screenPoint)
{
  double dx = screenPoint.getX() - mCentreX;
  // Minus to correct for coord re-mapping
  double dy = -(screenPoint.getY() - mCentreY);

  double inRads = Math.atan2(dy,dx);

  // We need to map to coord system when 0 degree is at 3 O'clock, 270 at 12 O'clock
  if (inRads < 0)
    inRads = Math.abs(inRads);
  else
    inRads = 2*Math.PI - inRads;

  return Math.toDegrees(inRads);
}
origin: stackoverflow.com

private final Point pp = new Point();
private JLabel image;
  Point cp = e.getPoint();
  Point vp = vport.getViewPosition();
  vp.translate(pp.x-cp.x, pp.y-cp.y);
  image.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
  pp.setLocation(cp);
  image.setCursor(hndCursor);
  pp.setLocation(e.getPoint());
  image.setCursor(defCursor);
  image.repaint();
origin: stackoverflow.com

Point myPoint = new Point( 0, 0 );
 System.out.println( myPoint );
 myPoint.setLocation( 1.0, 0.0 );
 System.out.println( myPoint );
 String myString = new String( "old String" );
 System.out.println( myString );
 myString.replaceAll( "old", "new" );
 System.out.println( myString );
origin: stackoverflow.com

private Point dragLocation  = new Point();
  setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
  setPreferredSize(new Dimension(500, 500));
  final JFrame f = new JFrame("Test");
  addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
  addMouseMotionListener(new MouseMotionAdapter() {
    @Override
    public void mouseDragged(MouseEvent e) {
      if (drag) {
        if (dragLocation.getX()> getWidth()-10 && dragLocation.getY()>getHeight()-10) {
          System.err.println("in");
          setSize((int)(getWidth()+(e.getPoint().getX()-dragLocation.getX())),
              (int)(getHeight()+(e.getPoint().getY()-dragLocation.getY())));
          dragLocation = e.getPoint();
  f.getContentPane().setLayout(new BorderLayout());
  f.getContentPane().add(this,BorderLayout.CENTER);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.pack();
  f.setVisible(true);
origin: stackoverflow.com

    Point point = e.getPoint();
    int width = getWidth();
    int height = getHeight();
        selectedCell = new Point(column, row);
    repaint();
addMouseMotionListener(mouseHandler);
Graphics2D g2d = (Graphics2D) g.create();
int width = getWidth();
int height = getHeight();
  for (int row = 0; row < rowCount; row++) {
    for (int col = 0; col < columnCount; col++) {
      Rectangle cell = new Rectangle(
          xOffset + (col * cellWidth),
          yOffset + (row * cellHeight),
origin: stackoverflow.com

basePanel.setLayout(new BorderLayout());
if (useSlideButton) {
  final JPanel statusPanel = new JPanel();
  basePanel.add(statusPanel, BorderLayout.SOUTH);
  statusPanel.add(new JButton("Slide Left") {
    private static final long serialVersionUID = 9204819004142223529L;
if (w instanceof JFrame) {
  final JFrame j = (JFrame) w;
  if (j.getContentPane().getComponents().length > 0) {
    throw new RuntimeException("ProgramCheck: Parent already contains content.");
  j.getContentPane().add(basePanel);
  ((JFrame) w).getGlassPane().setVisible(false);
  ((JWindow) w).setGlassPane(glassPane);
glassPane.setVisible(true);
  final Point p2 = new Point(0, 0);
  if (slideType == LEFT) {
    p2.x += w;
  basePanel.revalidate();
  if (useLoop) {
    final int max = (slideType == LEFT) || (slideType == RIGHT) ? w : h;
origin: stackoverflow.com

final JFrame frame = new JFrame("Image zoom");
frame.getContentPane().add(zoomPanel);
final Ticker t = new Ticker(zoomPanel);
frame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent we) {
    t.done();
    frame.dispose();
frame.setLocation(new Point(640, 0));
frame.pack();
frame.setVisible(true);
setSize(new Dimension(400, 400));
setMinimumSize(new Dimension(400, 400));
setPreferredSize(new Dimension(400, 400));
setOpaque(true);
repaint(40 + x * STEP, 45 + y * STEP, 40 + (x * STEP) - 3, 45 + (y * STEP) - 3);
g2.setColor(getBackground());
try {
    Rectangle rect = new Rectangle(p.x - 4, p.y - 4, 8, 8);
    final BufferedImage capture = robot.createScreenCapture(rect);
origin: stackoverflow.com

JFrame frame = new JFrame("FX");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null); // do the layout manually
frame.add(jButton);
frame.add(fxPanel);
frame.setVisible(true);
jButton.setSize(new Dimension(200, 27));
fxPanel.setSize(new Dimension(300, 300));
fxPanel.setLocation(new Point(0, 27));
frame.getContentPane().setPreferredSize(new Dimension(300, 327));
frame.pack();
frame.setResizable(false);
origin: stackoverflow.com

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
double xScale = ((double) getWidth() - (2 * padding) - labelPadding) / (scores.size() - 1);
double yScale = ((double) getHeight() - 2 * padding - labelPadding) / (getMaxScore() - getMinScore());
  int x1 = (int) (i * xScale + padding + labelPadding);
  int y1 = (int) ((getMaxScore() - scores.get(i)) * yScale + padding);
  graphPoints.add(new Point(x1, y1));
g2.fillRect(padding + labelPadding, padding, getWidth() - (2 * padding) - labelPadding, getHeight() - 2 * padding - labelPadding);
g2.setColor(Color.BLACK);
invalidate();
this.repaint();
mainPanel.setPreferredSize(new Dimension(800, 600));
JFrame frame = new JFrame("DrawGraph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame();
final JTextArea textArea = new JTextArea();
JScrollPane pane = new JScrollPane(textArea);
    + "Blabla\nBlabla\nBlabla\nBlabla\nBlabla\nBlabla\n");
textArea.setSelectionColor(Color.RED);
frame.add(pane);
frame.setSize(300, 120);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
    pos2 + turnToString2.length(),
    new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));    
int y = startIndex.y + (pane.getHeight() - 10);
System.out.println("Pane Height : " + pane.getHeight());
System.out.println("X : " + startIndex.x);
System.out.println("Y : " + y);
System.out.println("Y (pos2) : " + startIndex.y);
textArea.setCaretPosition(textArea.viewToModel(new Point(startIndex.x, y)));
pane.scrollRectToVisible(new Rectangle(startIndex.x, y));
origin: stackoverflow.com

this.add(map, BorderLayout.CENTER);
private final DecimalFormat df = new DecimalFormat(format);
private JLabel name = new JLabel("", JLabel.CENTER);
private Point point = new Point();
private JLabel position = new JLabel(toString(point), JLabel.CENTER);
private int blocks;
  super(new GridLayout(1, 0));
  name.setText(s);
  this.setBackground(hue.getColor());
      point.setLocation(0, 0);
      blocks = 0;
      update();
  position.setText(CabPanel.this.toString(point));
  odometer.setText(df.format(blocks));
  map.repaint();
  this.setPreferredSize(new Dimension(32 * SIZE, 32 * SIZE));
JFrame f = new JFrame("Dispatch");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
origin: stackoverflow.com

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
double xScale = ((double) getWidth() - 2 * BORDER_GAP) / (scores.size() - 1);
double yScale = ((double) getHeight() - 2 * BORDER_GAP) / (MAX_SCORE - 1);
  int x1 = (int) (i * xScale + BORDER_GAP);
  int y1 = (int) ((MAX_SCORE - scores.get(i)) * yScale + BORDER_GAP);
  graphPoints.add(new Point(x1, y1));
g2.drawLine(BORDER_GAP, getHeight() - BORDER_GAP, BORDER_GAP, BORDER_GAP);
g2.drawLine(BORDER_GAP, getHeight() - BORDER_GAP, getWidth() - BORDER_GAP, getHeight() - BORDER_GAP);
JFrame frame = new JFrame("DrawGraph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: stackoverflow.com

final JFrame frame = new JFrame("Gradient JButton Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new FlowLayout());
frame.add(JGradientButton.newInstance());
frame.setSize(new Dimension(300, 150)); // used for demonstration
frame.setLocationRelativeTo(null);
frame.setVisible(true);
  final Graphics2D g2 = (Graphics2D) g.create();
  g2.setPaint(new GradientPaint(
      new Point(0, 0), 
      Color.WHITE, 
      new Point(0, getHeight()), 
      Color.PINK.darker()));
  g2.fillRect(0, 0, getWidth(), getHeight());
  g2.dispose();
origin: stackoverflow.com

private Point startPoint = new Point(0, 0);
private Point rectLocale = new Point();
private Dimension rectSize = new Dimension();
private int zoom = 80;
  raw = new Robot().createScreenCapture(new Rectangle(
      Toolkit.getDefaultToolkit().getScreenSize()));
  MouseBehavior behavior = new MouseBehavior();
        g2d.drawRect(x2, y2, width2, height2);
      } else {
        g2d.draw(new Rectangle(rectLocale, rectSize));
  b.addMouseMotionListener(behavior);
  b.addMouseListener(behavior);
  b.addMouseWheelListener(behavior);
  JFrame f = new JFrame();
  f.setLocation(10, 10);
  f.setDefaultCloseOperation(3);
  f.add(b);
  f.pack();
  f.setVisible(true);
  public void mousePressed(MouseEvent e) {
    startPoint = e.getPoint();
    rectLocale = new Point();
    rectSize = new Dimension();
    capture = null;
origin: stackoverflow.com

int n = 6;  //Number of labels
int radius = 100;
Point centre = new Point(200,200);
 int dx = (int)(radius * Math.sin(theta));
 int dy = (int)(-radius * Math.cos(theta));
 Point p = new Point(centre.x + dx, centre.y + dy);
 points.add(p);
JFrame frame = new JFrame("Labels in a circle");
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (Point point : points) {
 JLabel label = new JLabel("Point " + count);
 panel.add(label);
 count++;
 layout.putConstraint(SpringLayout.WEST, label, point.x, SpringLayout.WEST, panel);
panel.setLayout(layout);
frame.add(panel);
frame.setVisible(true);
origin: stackoverflow.com

private Point p1 = new Point(100, 100);
private Point p2 = new Point(540, 380);
private boolean drawing;
  this.setPreferredSize(new Dimension(640, 480));
  this.addMouseListener(mouseHandler);
  this.addMouseMotionListener(mouseHandler);
    p1 = e.getPoint();
    p2 = p1;
    repaint();
    this.add(new MoveButton("\u2190", KeyEvent.VK_LEFT, -DELTA, 0));
    this.add(new MoveButton("\u2191", KeyEvent.VK_UP, 0, -DELTA));
    this.add(new MoveButton("\u2192", KeyEvent.VK_RIGHT, DELTA, 0));
    this.add(new MoveButton("\u2193", KeyEvent.VK_DOWN, 0, DELTA));
          LinePanel.this.p1.translate(dx, dy);
          LinePanel.this.p2.translate(dx, dy);
          LinePanel.this.repaint();
      ControlPanel.this.getInputMap(WHEN_IN_FOCUSED_WINDOW)
        .put(k, k.toString());
      ControlPanel.this.getActionMap()
        .put(k.toString(), new AbstractAction() {
origin: stackoverflow.com

public JComponent makeUI() {
 DragPanel p1 = new DragPanel();
 p1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
 p1.add(new JLabel(UIManager.getIcon("OptionPane.warningIcon")));
 p1.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
 p1.add(new JLabel("Label1"));
 p1.addMouseListener(handler);
 LabelTransferHandler th = new LabelTransferHandler();
 p1.setTransferHandler(th);
 p2.setBorder(BorderFactory.createLineBorder(Color.BLACK));
 p2.addMouseListener(handler);
 JFrame f = new JFrame();
 f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 f.getContentPane().add(new DragTest3().makeUI());
 f.setSize(320, 240);
 f.setLocationRelativeTo(null);
 f.setVisible(true);
  @Override public void dragMouseMoved(DragSourceDragEvent dsde) {
   Point pt = dsde.getLocation();
   pt.translate(5, 5); // offset
 Point pt = p.draggingLabel.getLocation();
origin: stackoverflow.com

fillCells.add(new Point(x, y));
repaint();
  JFrame window = new JFrame();
  window.setSize(840, 560);
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.add(grid);
  window.setVisible(true);
  grid.fillCell(0, 0);
  grid.fillCell(79, 0);
origin: stackoverflow.com

private static final int W = 640;
private static final int H = 480;
private Point textPt = new Point(W / 2, H / 2);
private Point mousePt;
  this.setFont(new Font("Serif", Font.ITALIC + Font.BOLD, 32));
  this.addMouseListener(new MouseAdapter() {
      repaint();
  this.addMouseMotionListener(new MouseMotionAdapter() {
      int dx = e.getX() - mousePt.x;
      int dy = e.getY() - mousePt.y;
      textPt.setLocation(textPt.x + dx, textPt.y + dy);
      mousePt = e.getPoint();
      repaint();
      JFrame f = new JFrame(TITLE);
      f.add(new MouseDragTest());
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.pack();
      f.setLocationRelativeTo(null);
      f.setVisible(true);
java.awtPoint

Javadoc

A point representing a location in (x,y) coordinate space, specified in integer precision.

Most used methods

  • <init>
    Constructs and initializes a point with the same location as the specified Point object.
  • getX
  • getY
  • setLocation
  • translate
    Translates this point, at location (x,y), by dx along the x axis and dy along the y axis so that it
  • equals
    Determines whether or not two points are equal. Two instances ofPoint are equal if the values of the
  • distance
  • clone
    Creates a new object of the same class and with the same contents as this object.
  • getLocation
    Returns the location of this point. This method is included for completeness, to parallel thegetLoca
  • move
    Moves this point to the specified location in the (x,y) coordinate plane. This method is identical w
  • distanceSq
  • hashCode
    Returns the hashcode for this Point.
  • distanceSq,
  • hashCode,
  • toString,
  • Add,
  • GetExX,
  • GetExY,
  • GetExZ,
  • SetX,
  • SetY,
  • SetZ

Popular in Java

  • Making http post requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now