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);
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)); } } }
@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); }
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);
} 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);
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);
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);
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);
JPanel panel = new JPanel(); panel.setLayout(null); JLabel label = new JLabel("text"); label.setLocation(50, 20); panel.add(label);
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);
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);
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);
//p.add(new JLabel(ico)); JLabel label = new JLabel(ico); label.setSize( label.getPreferredSize()); label.setLocation(...); p.add(label);
JLabel text = new JLabel("Some text"); text.setSize( label.getPreferredSize() ); text.setLocation(...); label.add( text );
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. }
JLabel label = new JLabel("your text"); label.setLocation(0, 100); label.setSize(20, 100); label.paint(g); // g is your Graphics2D context
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(); }
/** * 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); }
@ScriptFunction @Override public void setTop(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustTop(this, aValue); } super.setLocation(getLeft(), aValue); }
@ScriptFunction @Override public void setLeft(int aValue) { if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) { MarginLayout.ajustLeft(this, aValue); } super.setLocation(aValue, getTop()); }