How to determine the size of a JLabel?

2

I'm creating a program, and I'm making its menu.

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

    
asked by anonymous 03.06.2015 / 01:21

1 answer

2

See getSize() method and the class Dimension :

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