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

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

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

JLabel.setLocation介绍

暂无

代码示例

代码示例来源:origin: kiegroup/optaplanner

employeeLabel.setOpaque(true);
employeeLabel.setToolTipText(employee.getToolText());
employeeLabel.setLocation(0, HEADER_ROW_HEIGHT + employeeIndex * ROW_HEIGHT);
employeeLabel.setSize(HEADER_COLUMN_WIDTH, ROW_HEIGHT);
employeeLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
JLabel timeLabel = new JLabel((hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes);
timeLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
timeLabel.setLocation(x, 0);
timeLabel.setSize(TIME_COLUMN_WIDTH, ROW_HEIGHT);
add(timeLabel);

代码示例来源:origin: magefree/mage

private void drawOn(JPanel panel, String value) {
    List<Image> images = new ArrayList<>();
    value = value.toUpperCase(Locale.ENGLISH);
    for (int i = 0; i < value.length(); i++) {
      char symbol = value.charAt(i);
      Image image = ManaSymbols.getSizedManaSymbol(String.valueOf(symbol));
      if (image != null) {
        images.add(image);
      }
    }

    if (images.size() == value.length()) {
      int dx = 0;
      for (Image image : images) {
        ImageIcon icon = new ImageIcon(image);
        JLabel imageLabel = new JLabel();
        imageLabel.setSize(11, 11);
        imageLabel.setLocation(dx, 0);
        imageLabel.setIcon(icon);
        panel.add(imageLabel);
        dx += 13;
      }
    } else {
      String s = value.replace("B", "{B}").replace("R", "{R}").replace("G", "{G}").replace("W", "{W}").replace("U", "{U}").replace("X", "{X}");
      panel.add(new JLabel(s));
    }
  }
}

代码示例来源:origin: RaiMan/SikuliX2

@Override
public void setName(String name) {
 if (label == null) {
  super.setName(name);
  this.label = new JLabel(name);
  add(label);
 }
 label.setFont(new Font("sansserif", Font.BOLD, fontSize));
 label.setForeground(colorText);
 Dimension s = label.getPreferredSize();
 label.setLocation((int) (PADDING_X/2), (int) (PADDING_Y/2));
 label.setSize(s);
 s.height += PADDING_Y;
 s.width += PADDING_X;
 setActualSize(s);
}

代码示例来源:origin: magefree/mage

insertArrow.setLocation((cardWidth + GRID_PADDING) * col + GRID_PADDING / 2 - 32, curY);
} else {
  insertArrow.setLocation((cardWidth + GRID_PADDING) * col + GRID_PADDING + cardWidth / 2 - 32, curY + stackInsertIndex * cardTopHeight - 32);

代码示例来源:origin: magefree/mage

} else {
  countLabel.setText(String.valueOf(stack.size()));
  countLabel.setLocation(GRID_PADDING + (cardWidth + GRID_PADDING) * colIndex, currentY - COUNT_LABEL_HEIGHT);
  countLabel.setSize(cardWidth, COUNT_LABEL_HEIGHT);
  countLabel.setVisible(true);

代码示例来源:origin: RaiMan/SikuliX2

symbol.setSize(size);
symbol.setForeground(Color.white);
symbol.setLocation(region.x + region.w / 2 - size.width / 2,
    region.y + region.h / 2 - size.height / 2);

代码示例来源:origin: magefree/mage

int size = cardWidth > WIDTH_LIMIT ? 40 : 20;
minusCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size * 2);
minusCounterLabel.setSize(size, size);
plusCounterLabel.setLocation(5, counterPanel.getHeight() - size * 2);
plusCounterLabel.setSize(size, size);
loyaltyCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size);
loyaltyCounterLabel.setSize(size, size);
otherCounterLabel.setLocation(5, counterPanel.getHeight() - size);
otherCounterLabel.setSize(size, size);

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

JLabel text = (JLabel)e.getSource();
int width = getContentPane().getSize().width;
int height = getContentPane().getSize().height;
int x = (int)(Math.random()*(width-30));
int y = (int)(Math.random()*(height-30));
text.setLocation(x,y);

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

JPanel panel = new JPanel();
panel.setLayout(null);
JLabel label = new JLabel("text");
label.setLocation(50, 20);
panel.add(label);

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

JLabel label2 = new JLabel( new ColorIcon(Color.GREEN, 40, 40) );
label2.setSize( label2.getPreferredSize() );
label2.setLocation(500, 500);
contentPane.add( label2 );

KeyboardAnimation animation2 = new KeyboardAnimation(label2, 24);
animation2.addAction("A", -3,  0);
animation2.addAction("D", 3,  0);
animation2.addAction("W",    0, -3);
animation2.addAction("S",  0,  3);

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

JLabel dice1 = new JLabel();
 ImageIcon one = new ImageIcon("dice/1.png");
 //set dice1 position
 dice1.setLocation(20, 100);
 dice1.setSize(115, 115);
 dice1.setIcon(one);
 gamepanel.add(dice1);

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

ImageIcon yourImage = new ImageIcon("C:/path/to/your/file/cough.jpg");
 JLabel yourLabel = new JLabel();
 yourLabel.setLocation(x,y);
 yourLabel.setSize(width, heigh);
 yourLabel.setIcon(yourImage);
 yourFrame.add(yourLabel);

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

//p.add(new JLabel(ico));
JLabel label = new JLabel(ico);
label.setSize( label.getPreferredSize());
label.setLocation(...);
p.add(label);

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

JLabel text = new JLabel("Some text");
text.setSize( label.getPreferredSize() );
text.setLocation(...);
label.add( text );

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

public void createLabel(String text, String name, Dimension size, Point location) {
    JLabel label = new JLabel(text); // Creates the JLabel
    label.setName(name); // Sets the name
    label.setSize(size); // Sets the size
    label.setLocation(location); // Sets the location
    vecLabel.add(label); // Adds the JLabel to the vecLabels. ()
    add(label); // Adds the label to the JFrame.
}

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

JLabel label = new JLabel("your text");
label.setLocation(0, 100); 
label.setSize(20, 100);
label.paint(g); // g is your Graphics2D context

代码示例来源: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: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

/**
 * A call of this method should validate the positions of the panels
 * components.
 */
@Override
public void relocate()
{
  int w = 480, h = 245;
  int x = (this.getWidth() - w) / 2, y = (this.getHeight() - h) / 2;
  diffToolLabel.setLocation(x, y);
  diffToolField.setLocation(x + 160, y);
  diffToolLogLevelComboBox.setLocation(x + 380, y);
}

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

@ScriptFunction
@Override
public void setTop(int aValue) {
  if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
    MarginLayout.ajustTop(this, aValue);
  }
  super.setLocation(getLeft(), aValue);
}

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

@ScriptFunction
@Override
public void setLeft(int aValue) {
  if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
    MarginLayout.ajustLeft(this, aValue);
  }
  super.setLocation(aValue, getTop());
}

相关文章

微信公众号

最新文章

更多

JLabel类方法