Question

I have a JPanel with a null layout (this should stay), and a simple Etched Border. Now i want to set the location of a button at the deapest point; for this i need the width of the border. How can i get this? Component.insets().bottom works fine, but this method is deprecated. Is there something newer? Thanks!

Edit: sry for my english. And Thanks for downvotingm.. -.-

Was it helpful?

Solution

int base = myComponent.getInsets().bottom;

From the docs

Deprecated. As of JDK version 1.1, replaced by getInsets().

Swing was designed to use layout managers. Definitely better to use one for positioning & sizing components. It should remove the necessity to determine the base location of your component.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top