myY = getY();
public static double distance(Point p, JComponent comp) { Point2D.Float center = // note: use (0, 0) instead of (getX(), getY()) // if the Point 'p' is in the coordinates of 'comp' // instead of the parent of 'comp' new Point2D.Float(comp.getX(), comp.getY()); center.x += comp.getWidth() / 2f; center.y += comp.getHeight() / 2f; return center.distance(p); }
public static Rectangle placeAbove(JComponent j, int a) { int x= j.getX(); int y= j.getY(); int w= j.getWidth(); int h= j.getHeight(); y=(y-h)-a; //return our new bounds projected in a Rectangle Object return new Rectangle(x, y, w, h); }
public void setImageWidthFixed(boolean imageWidthFixed) { if (this.imageWidthFixed == imageWidthFixed) { return; } this.imageWidthFixed = imageWidthFixed; if (this.imageWidthFixed) { setSliderBoxBounds(0, sliderBox.getY(), imageWidth, sliderBox.getHeight(), true); } }
public void setImageWidthFixed(boolean imageWidthFixed) { if (this.imageWidthFixed == imageWidthFixed) { return; } this.imageWidthFixed = imageWidthFixed; if (this.imageWidthFixed) { setSliderBoxBounds(0, sliderBox.getY(), imageWidth, sliderBox.getHeight(), true); } }
public void mouseDragged(MouseEvent e) { if (e.getSource() == label2) { JComponent jc = (JComponent)e.getSource(); jc.setLocation(jc.getX()+e.getX()-clicX, jc.getY()+e.getY()-clicY); }
public void mouseDragged(MouseEvent e) { if (drag == true) { JComponent jc = (JComponent)e.getSource(); jc.setLocation(jc.getX()+e.getX(), jc.getY()+e.getY()); } }
/** * Called when the mouse is pressed over the JComponent. * Saves the point (which is measured relative to the JComponent's corner) * over which the mouse was pressed. */ public void mousePressed(MouseEvent e) { myComponent.setCursor(closedHandCursor); mPressedX = e.getX(); mPressedY = e.getY(); oldLocX = myComponent.getX(); oldLocY = myComponent.getY(); }
/** * Paints the component with the current zoom scale * @param g graphics * @param c component */ @Override public void paint(Graphics g, JComponent c) { g.clearRect(c.getX(), c.getY(), c.getWidth(), c.getHeight()); Graphics2D g2 = (Graphics2D) g; g2.scale(zoom, zoom); super.paint(g2, c); }
public void run() { if (repaintCallback != null) { repaintCallback.setBounds(repaintCallback.getX(), repaintCallback.getY(), repaintCallback.getWidth(), repaintCallback.getHeight()); repaintCallback.repaint(); } } });
public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if(page > 0) return Printable.NO_SUCH_PAGE; Graphics2D g2 = (Graphics2D)g; g2.translate(pf.getImageableX(), pf.getImageableY()); for(JComponent item : items) { g2.translate(item.getX(), item.getY()); item.printAll(g); g2.translate(-item.getX(), -item.getY()); // bring all back to default coordinates } return Printable.PAGE_EXISTS; }
private int getRefY(NodeView sibling) { return sibling.getY() + sibling.getContent().getY(); }
public static void repaintRequest(JComponent c) { RepaintManager.currentManager(c).addDirtyRegion( c, c.getX(), c.getY(), c.getWidth(), c.getHeight()); }
private void dispatchMouseEvent(MouseEvent e, JComponent c) { MouseEvent me = new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiers(), e.getX()-c.getX(), e.getY()-c.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), false, e.getButton()); c.dispatchEvent(me); if (me.isConsumed()) e.consume(); }
/** * Called after the canvas is set on {@code g2d} but before any painting is * done. This should setup the matrices and ask {@code g2d} to setup any * client state. */ protected void prePaint(GLAutoDrawable drawable) { setupViewport(drawable); g2d.prePaint(drawable); g2d.translate(comp.getX(), comp.getY()); g2d.clipRect(0, 0, comp.getWidth(), comp.getHeight()); }
/** * Called before any painting is done. This should setup the matrices and ask * the {@code GLGraphics2D} object to setup any client state. */ protected void prePaint(GLAutoDrawable drawable) { setupViewport(drawable); g2d.prePaint(drawable.getContext()); // clip to only the component we're painting g2d.translate(comp.getX(), comp.getY()); g2d.clipRect(0, 0, comp.getWidth(), comp.getHeight()); }
private boolean isTabFullyVisible( ITab tab ) { switch( _tabContainer.getTabPosition() ) { case TOP: case BOTTOM: return tab.getComponent().getX() + tab.getComponent().getWidth() <= _tabContainer.getWidth(); case LEFT: case RIGHT: return tab.getComponent().getY() + tab.getComponent().getHeight() <= _tabContainer.getHeight(); } throw new IllegalStateException(); }
private boolean isTabFullyVisible( ITab tab ) { switch( _tabContainer.getTabPosition() ) { case TOP: case BOTTOM: return tab.getComponent().getX() + tab.getComponent().getWidth() <= _tabContainer.getWidth(); case LEFT: case RIGHT: return tab.getComponent().getY() + tab.getComponent().getHeight() <= _tabContainer.getHeight(); } throw new IllegalStateException(); }