javax.swing.JLabel.getLocation()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中javax.swing.JLabel.getLocation()方法的一些代码示例,展示了JLabel.getLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getLocation()方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getLocation

JLabel.getLocation介绍

暂无

代码示例

代码示例来源:origin: nl.cloudfarming.client/geometry-shape-type

@Override
public void paint (Graphics g) {
  super.paint(g);
  
  // SKIP
  g.setColor(palette.getColorForValue(ImportType.SKIP));
  int xSkipLoc = skipLabel.getLocation().x + LABEL_CUBE_DISTANCE;
  int ySkipLoc = skipLabel.getLocation().y;
  g.fillRect(xSkipLoc, ySkipLoc, COLORCUBE_WIDTH, COLORCUBE_HEIGHT);
  
  // IMPORT
  g.setColor(palette.getColorForValue(ImportType.IMPORT));
  int xImportLoc = importLabel.getLocation().x + LABEL_CUBE_DISTANCE;
  int yImportLoc = importLabel.getLocation().y;
  g.fillRect(xImportLoc, yImportLoc, COLORCUBE_WIDTH, COLORCUBE_HEIGHT);
}

代码示例来源:origin: stackoverflow.com

Point loc = label.getLocation();
Point pos = label.getLocationOnScreen();
Window win = SwingUtilities.getWindowAncestor(this);
Point wLoc = win.getLocation();
Point rPos = SwingUtilities.convertPoint(label, label.getLocation(), win);
JRootPane rootPane = SwingUtilities.getRootPane(this);
Point cPos = SwingUtilities.convertPoint(label, loc, rootPane.getContentPane());

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = LEFT_JSDOC)
@Override
public int getLeft() {
  return super.getLocation().x;
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

public boolean isMouseXOverLabel(Point p) {
    Point l = totalCount.getLocation();
    if (p.x >= l.x && p.x <= (l.x + totalCount.getWidth())) {
      return true;
    }
    return false;
  }
}

代码示例来源:origin: nl.cloudfarming.client/field-shape-type

@Override
public void paint (Graphics g) {
  super.paint(g);
  
  // SKIP
  g.setColor(palette.getColorForValue(ImportType.SKIP));
  int xSkipLoc = skipLabel.getLocation().x + LABEL_CUBE_DISTANCE;
  int ySkipLoc = skipLabel.getLocation().y;
  g.fillRect(xSkipLoc, ySkipLoc, COLORCUBE_WIDTH, COLORCUBE_HEIGHT);
  
  // IMPORT
  g.setColor(palette.getColorForValue(ImportType.IMPORT));
  int xImportLoc = importLabel.getLocation().x + LABEL_CUBE_DISTANCE;
  int yImportLoc = importLabel.getLocation().y;
  g.fillRect(xImportLoc, yImportLoc, COLORCUBE_WIDTH, COLORCUBE_HEIGHT);
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@ScriptFunction(jsDoc = TOP_JSDOC)
@Override
public int getTop() {
  return super.getLocation().y;
}

代码示例来源:origin: stackoverflow.com

public void mouseClicked(MouseEvent ae) {
 JLabel src = (JLabel) ae.getSource();
 src.setLocation(src.getLocation().x + delta_x, src.getLocation().y + delta_y);
 src.getParent().repaint();
}

代码示例来源:origin: stackoverflow.com

public void actionPerformed(ActionEvent e){
  label.setLocation(label.getLocation().x, label.getLocation().y+1);

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * Calculates the locatioin of the context menu.
 *
 * @return the upper-left corner location.
 * @since 3.4.2
 */
protected Point calculateContextMenuLocation() {
  Point location = _label.getLocation();
  return new Point(location.x + (_label.getIcon() == null ? 1 : _label.getIcon().getIconWidth() / 2), location.y + _label.getHeight() + 1);
}

代码示例来源:origin: stackoverflow.com

label.setLocation(label.getLocation().x + me.getX() - pX, 
      label.getLocation().y + me.getY() - pY);
jPanel1.revalidate();
jPanel1.repaint();

代码示例来源:origin: stackoverflow.com

frame.setVisible(true);
System.out.println("lable.location: " + label.getLocation());
System.out.println("label to inner: " + SwingUtilities.convertPoint(label, new Point(0, 0), inner));
System.out.println("label to outter: " + SwingUtilities.convertPoint(label, new Point(0, 0), outter));

代码示例来源:origin: stackoverflow.com

int w = img.getWidth();
 int h = img.getHeight();
 frame.setSize(w, h);        // I just did that to make the example easier to understand
 JLabel label = new JLabel(new ImageIcon(img));  // so your "background" label with the map image
 // we need this dot label somewhere else and it must be final
 final JLabel dot = new JLabel(new ImageIcon(redDot));  // and your dot label with the dot image as icon
 label.add(dot);
 frame.add(label);
 label.setBounds(0, 0, w, h);    // just for the example, the map-label is set to  fill the frame
 dot.setBounds(50, 50, 60, 60);  // setBounds will handle both: location and size
 frame.pack();  // pack will do all the stuff to make sure everything is painted and has the correct size when the window becomes visible
 // and here comes the animation:
 // my solution is to use a swing timer. Swing timers execute in a background thread and are perfectly suited to "update" any swing component without blocking the User Input thread.
 // this timer will call the actionPerformed() of the ActionListener every 500 ms
 Timer timer = new Timer(500, new ActionListener(){
   @Override
   public void actionPerformed(ActionEvent e){
     Point location = dot.getLocation();    // get current location of the dot
     dot.setLocation(location.x + 10, location.y + 10);  // just set a new location 10 px further right and further down
     dot.revalidate();  // revalidate, so the updated position will be taken into account when the dot label will get painted again
   }
 });
 timer.start();   // start the timer and it will immediately start moving your dot on the img

代码示例来源:origin: stackoverflow.com

Point point = result.getLocation();
point.x += xDelta;
point.y += yDelta;

代码示例来源:origin: stackoverflow.com

Point loc = label1.getLocation();
System.out.println(floc);
popup1.setLocation((int)(floc.getX()+loc.getX())-20, (int)(floc.getY()+loc.getY())+40);
loc = label2.getLocation();
popup2.setLocation((int)(floc.getX()+loc.getX())+20, (int)(floc.getY()+loc.getY())+40);

代码示例来源:origin: stackoverflow.com

super.doLayout();
label.setSize(label.getPreferredSize());
label.getLocation(p);

相关文章

JLabel类方法