private void readPositionFromComponent(Component component) { isFullScreen = false; windowWidth = component.getWidth(); windowHeight = component.getHeight(); windowX = component.getX(); windowY = component.getY(); }
int windowY = 0; windowX = container.getX() + textField.getX() + 5; if (suggestionsPanel.getHeight() > autoSuggestionPopUpWindow.getMinimumSize().height) { windowY = container.getY() + textField.getY() + textField.getHeight() + autoSuggestionPopUpWindow.getMinimumSize().height;
@Override public void mousePressed(MouseEvent e) { popup.applyComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault())); if (ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT) { radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 6)); } else { radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0)); } popup.show( e.getComponent(), ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getComponent().getX() - e.getComponent().getWidth() - popup.getWidth() : e.getComponent().getX(), e.getComponent().getY() + e.getComponent().getWidth() ); popup.setLocation( ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getComponent().getLocationOnScreen().x + e.getComponent().getWidth() - popup.getWidth() : e.getComponent().getLocationOnScreen().x, e.getComponent().getLocationOnScreen().y + e.getComponent().getWidth() ); } });
public static void keepComponentInsideFrame(int centerX, int centerY, Component component) { Rectangle frameRec = MageFrame.getInstance().getBounds(); boolean setLocation = false; if (component.getX() > (frameRec.width - OVERLAP_LIMIT)) { setLocation = true; } if (component.getY() > (frameRec.height - OVERLAP_LIMIT)) { setLocation = true; } if (setLocation) { component.setLocation(centerX, centerY); } }
int x = comp.getX(); if (x <= 0) { comp.setLocation(0, 0);
public static void convertPointFromAncestor(final Component ancestor, final Point p, Component c) { int x, y; while (c != ancestor && c != null) { x = c.getX(); y = c.getY(); p.x -= x; p.y -= y; c = c.getParent(); }; }
public static void convertPointToAncestor(final Component from, final Point p, final Component destination) { int x, y; for (Component c = from; c != destination && c != null; c = c.getParent()) { x = c.getX(); y = c.getY(); p.x += x; p.y += y; }; }
public void paintIcon(Component c, Graphics g, int x, int y) { super.setColor(new Color(10, 10, 10, 25)); super.paintIcon(c, g, x, y); g2d.setFont(new Font("SansSerif", Font.BOLD, 24)); g2d.setColor(Color.DARK_GRAY); g2d.drawString(value.toString(), c.getX() + 7, (int) ((c.getHeight() / 2) + 7)); g2d.setFont(new Font("SansSerif", Font.BOLD, 12)); } };
public void paintIcon(Component c, Graphics g, int x, int y) { super.setColor(new Color(10, 10, 10, 25)); super.paintIcon(c, g, x, y); g2d.setFont(new Font("SansSerif", Font.BOLD, 24)); g2d.setColor(Color.DARK_GRAY); g2d.drawString(value.toString(), c.getX() + 7, (int) ((c.getHeight() / 2) + 7)); g2d.setFont(new Font("SansSerif", Font.BOLD, 12)); } };
/** * Centers the first component on the second */ public static void center(Component componentToMove, Component componentToCenterOn) { Dimension componentToCenterOnSize = componentToCenterOn.getSize(); componentToMove.setLocation( componentToCenterOn.getX() + ((componentToCenterOnSize.width - componentToMove.getWidth()) / 2), componentToCenterOn.getY() + ((componentToCenterOnSize.height - componentToMove.getHeight()) / 2)); }
public void paintIcon(Component c, Graphics g, int x, int y) { super.setColor(new Color(10, 10, 10, 0)); super.paintIcon(c, g, x, y); g2d.setFont(new Font("SansSerif", Font.BOLD, 14)); g2d.setColor(Color.DARK_GRAY); final Font font = (Font) value; g2d.setFont(new Font(font.getFontName(), font.getStyle(), 40)); g2d.setColor(new Color(10, 10, 10, 40)); g2d.drawString("Font", c.getX() + 15, c.getY() - 10); g2d.setFont(new Font("SansSerif", Font.BOLD, 14)); } };
private String str(final Object obj) { if( null == obj ) { return "0xnil: null"; } else if( obj instanceof Component ) { final Component c = (Component)obj; return id(obj)+": "+c.getClass().getSimpleName()+"[visible "+c.isVisible()+", showing "+c.isShowing()+", valid "+c.isValid()+ ", displayable "+c.isDisplayable()+", "+c.getX()+"/"+c.getY()+" "+c.getWidth()+"x"+c.getHeight()+"]"; } else { return id(obj)+": "+obj.getClass().getSimpleName()+"[..]"; } } private String s(final ComponentEvent e) {
protected void refreshBorder() { if ( getComponent().getParent() != null ) { Component papi = getComponent(); papi.getParent().repaint( papi.getX()-5, papi.getY()-5, papi.getWidth()+10, papi.getHeight()+10); } }
public class Basic { public static void moveLeft(Component component, int offset) { component.setLocation(component.getX() - offset, component.getY()); } }
@Override public void componentMoved(ComponentEvent evt) { prefs.putInt(name + ".x", evt.getComponent().getX()); prefs.putInt(name + ".y", evt.getComponent().getY()); }
@Override public boolean contains(final int x, final int y) { if (super.contains(x, y)) return true; for(int i = 0; i < getComponentCount(); i++){ final Component comp = getComponent(i); if(comp.isVisible() && comp.contains(x-comp.getX(), y-comp.getY())) return true; } return false; }
public boolean titleContains( int x, int y ){ DockTitle title = getTitle(); if( title == null ) return false; Component component = getComponent( title ); Point point = new Point( x, y ); point = SwingUtilities.convertPoint( this, point, component ); point.x -= component.getX(); point.y -= component.getY(); return component.contains( point ); }
/** * Packs this dialog, makes it non-resizable and visible. */ public void showDialog() { pack(); if(locationRelativeComp==null) DialogToolkit.centerOnScreen(this); else setLocation(locationRelativeComp.getX()+(locationRelativeComp.getWidth()-getWidth())/2, locationRelativeComp.getY()+(locationRelativeComp.getHeight()-getHeight())/2); setVisible(true); }
private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved if (isShowing() && !isMaximum() && isRecording()) { final Component c = evt.getComponent(); prefs.putInt(getKey("x"), c.getX()); prefs.putInt(getKey("y"), c.getY()); } }//GEN-LAST:event_formComponentMoved
public void relocate(Component c) { if (c.getX()<0 || c.getY()<0) { Point t = c.getLocation(); if (t.x<0) t.x=0; if (t.y<0) t.y=0; c.setLocation(t); invalidate(); } } }