private void keepAwake() { logger.log(Level.INFO, "Moving the mouse location slightly to keep the computer awake."); try { Robot hal = new Robot(); Point pObj = MouseInfo.getPointerInfo().getLocation(); hal.mouseMove(pObj.x + 1, pObj.y + 1); hal.mouseMove(pObj.x - 1, pObj.y - 1); pObj = MouseInfo.getPointerInfo().getLocation(); logger.log(Level.INFO, pObj.toString() + "x>>" + pObj.x + " y>>" + pObj.y); } catch (AWTException | NullPointerException ex) { Logger.getLogger(GUIBackend.class.getName()).log(Level.SEVERE, null, ex); } }
if (((JLabel) p).getText().isEmpty()) { Point spot = ((JLabel) p).getLocation(); ((JLabel) p).setText(spot.toString()); }
while(true){ hal.delay(1000 * 30); Point pObj = MouseInfo.getPointerInfo().getLocation(); System.out.println(pObj.toString() + "x>>" + pObj.x + " y>>" + pObj.y); hal.mouseMove(pObj.x + 1, pObj.y + 1); hal.mouseMove(pObj.x - 1, pObj.y - 1); pObj = MouseInfo.getPointerInfo().getLocation(); System.out.println(pObj.toString() + "x>>" + pObj.x + " y>>" + pObj.y); }
@Override public String toString() { return element.toString() + ":" + p.toString(); } }
@Override public String toString() { return this.getClass().getSimpleName() + " {" + this.segmentNumber + ", '" + this.title + "', " + this.location.toString() + "}"; } }
Point myPoint = new Point(x, y); String pointString = myPoint.toString();
public static void main(String []args) { Point point = new Point(10, 20); System.out.println(point.toString()); }
final StringBuilder builder = new Stringbuilder(); final List<Point> list = new ArrayList<Point>(); list.add(new Point(0, 0)); list.add(new Point(1, 0)); for(final Point p : list) { builder.append(p.toString()).append(";"); } properties.setProperty("list", builder.toString());
int count = 0; p = new Point(p.x-1, p.y-1); // new point here if (data.contains(p)) { count++; } else if (addingDeadCells) { deadCellsToCheck.add(p); for (Point z : deadCellsToCheck) { System.out.println(z.toString() + " " + z.hashCode()); } System.out.println(); }
Point spot = new Point(); Component currComponent = p; while ( currComponent != null && currComponent != mainPanel ) { Point relativeLocation = currComponent.getLocation(); spot.translate( relativeLocation.x, relativeLocation.y ); currComponent = currComponent.getParent(); } ((JLabel) p).setText(spot.toString());
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("caret: ").append(caret).append('\n'); builder.append("caretLine: ").append(caretLine).append('\n'); builder.append("caretScreenLine: ").append(caretScreenLine) .append('\n'); builder.append("electricScroll: ").append(electricScroll).append('\n'); builder.append("horizontalOffset: ").append(horizontalOffset) .append('\n'); builder.append("magicCaret: ").append(magicCaret).append('\n'); builder.append("offsetXY").append(offsetXY.toString()).append('\n'); builder.append("oldCaretLine: ").append(oldCaretLine).append('\n'); builder.append("screenLastLine: ").append(screenLastLine).append('\n'); builder.append("visibleLines: ").append(visibleLines).append('\n'); builder.append("firstPhysicalLine: ").append(getFirstPhysicalLine()) .append('\n'); builder.append("physLastLine: ").append(physLastLine).append('\n'); return builder.toString(); } // }}}
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Point pointInTable = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(pointInTable, table); Rectangle r = table.getCellRect(row, column, false); Point p = new Point(pointInTable.x - r.x, pointInTable.y - r.y); table.setToolTipText(p.toString()); return renderer; }
JTable testTable = new JTable(new Object[][]{{"Value 1", null}}, new Object[] {"Column 1", "Column 2"}) { @Override public String getToolTipText(MouseEvent event) { JTable table = (JTable)event.getSource(); int column = table.columnAtPoint( event.getPoint() ); if (column == 1) { int row = table.rowAtPoint( event.getPoint() ); Rectangle r = table.getCellRect(row, column, false); Point p = new Point(event.getX() - r.x, event.getY() - r.y); // System.out.println("Width from getToolTipText = " + r.width); return p.toString(); } return super.getToolTipText(event); } };
public void positions(Container p1) { for (Component p : p1.getComponents()) { if (p instanceof JLabel) { try { if (((JLabel) p).getText().isEmpty()) { Rectangle r = p.getBounds(); // Panel of jlabel bounds compared to the main panels bounds r = SwingUtilities.convertRectangle(p.getParent(), r, mainPanel); // Wrong spot this is relative to the first panel Point spot = ((JLabel) p).getLocation(); ((JLabel) p).setText("x=" + spot.getX() + ", y=" + spot.getY()); // the r.toString() is the correct position as it is relative to the parent component System.out.println("Position: " + spot.toString() + "\tr: " + r.toString()); } } catch (NullPointerException | IllegalComponentStateException e) { } //System.out.println(e.getMessage()); } else { if (p instanceof JPanel) { positions((Container) p); } } } }
return "Circle[" + this.center.toString() + ", " + this.radius + "]";
public void setLocation(Point location) { this.location = location; log.info("New location: " + location.toString()); update(); } }
assert this.name != null && this.location != null; this.rep = '{' + this.name + ", (" + this.location.toString() + ')';
g2.setColor(Color.red); if (!(mouseCoords == null)) { g2.drawString(mouseCoords.toString(), 10, getHeight() - 10);