How to determine the size of a Jlabel?

Asked

Viewed 764 times

2

I’m creating a program, and I’m making his menu.

But to make the menu, I need to create a button and I’m creating this button using images with the JLabel and using the MouseListener. However, I need to know how to determine the size of a JLabel to facilitate.

1 answer

2

See the method getSize() and the class Dimension:

JLabel label = ...
Dimension d = label.getSize();
System.out.println("Largura: " + d.width + " - Altura: " + d.height);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.