本文整理了Java中javax.swing.JComponent.getX()
方法的一些代码示例,展示了JComponent.getX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.getX()
方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:getX
暂无
代码示例来源:origin: stackoverflow.com
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;
代码示例来源:origin: stackoverflow.com
screenY = e.getYOnScreen();
myX = getX();
myY = getY();
代码示例来源:origin: stackoverflow.com
g2d.setColor(Color.blue);
g2d.setStroke(s);
int x1 = one.getX() + one.getWidth() / 2;
int y1 = one.getY() + one.getHeight() / 2;
int x2 = two.getX() + two.getWidth() / 2;
int y2 = two.getY() + two.getHeight() / 2;
g2d.drawLine(x1, y1, x2, y2);
代码示例来源:origin: stackoverflow.com
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);
}
代码示例来源:origin: senbox-org/snap-desktop
public void setImageHeightFixed(boolean imageHeightFixed) {
if (this.imageHeightFixed == imageHeightFixed) {
return;
}
this.imageHeightFixed = imageHeightFixed;
if (this.imageHeightFixed) {
setSliderBoxBounds(sliderBox.getX(), 0, sliderBox.getWidth(), imageHeight, true);
}
}
代码示例来源:origin: bcdev/beam
public void setImageHeightFixed(boolean imageHeightFixed) {
if (this.imageHeightFixed == imageHeightFixed) {
return;
}
this.imageHeightFixed = imageHeightFixed;
if (this.imageHeightFixed) {
setSliderBoxBounds(sliderBox.getX(), 0, sliderBox.getWidth(), imageHeight, true);
}
}
代码示例来源:origin: stackoverflow.com
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);
}
代码示例来源:origin: stackoverflow.com
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);
}
代码示例来源:origin: stackoverflow.com
public void mouseDragged(MouseEvent e)
{
if (drag == true)
{
JComponent jc = (JComponent)e.getSource();
jc.setLocation(jc.getX()+e.getX(), jc.getY()+e.getY());
}
}
代码示例来源:origin: mikaelhg/openblocks
/**
* 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();
}
代码示例来源:origin: sarahtattersall/PIPE
/**
* 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);
}
代码示例来源:origin: Spoutcraft/LegacyLauncher
public void run() {
if (repaintCallback != null) {
repaintCallback.setBounds(repaintCallback.getX(), repaintCallback.getY(), repaintCallback.getWidth(), repaintCallback.getHeight());
repaintCallback.repaint();
}
}
});
代码示例来源:origin: eu.mihosoft.vrl/vrl
public static void repaintRequest(JComponent c) {
RepaintManager.currentManager(c).addDirtyRegion(
c, c.getX(), c.getY(), c.getWidth(), c.getHeight());
}
代码示例来源:origin: de.sciss/jtreetable
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();
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
private boolean isInView( ITab tab )
{
return tab.getComponent().getX() + tab.getComponent().getWidth() <= getWidth();
}
代码示例来源:origin: mikaelhg/openblocks
/**
* @param page the desired page to switch view to
*
* @requires page != null
* @modifies the ghorizontal boundedrangemodel of this blockcanvas
* @effects Switches the canvas view to the specified page.
*/
public void switchViewToPage(Page page) {
scrollPane.getHorizontalModel().setValue(page.getJComponent().getX());
}
代码示例来源:origin: com.harium.propan/propan-jogl
/**
* 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());
}
代码示例来源:origin: com.github.insubstantial/flamingo
@Override
public Point getKeyTipAnchorCenterPoint() {
if (this.ribbonComponent.isSimpleWrapper()) {
return new Point(
this.ribbonComponent.getMainComponent().getX() + 10,
this.ribbonComponent.getHeight());
} else {
return new Point(this.captionLabel.getX(), this.ribbonComponent
.getHeight());
}
}
代码示例来源:origin: brandonborkholder/glg2d
/**
* 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());
}
代码示例来源:origin: khuxtable/seaglass
public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) {
super.setBoundsForFrame(f, newX, newY, newWidth, newHeight);
if (taskBar != null && newY >= taskBar.getY()) {
f.setLocation(f.getX(), taskBar.getY() - f.getInsets().top);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!