-1

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.. -.-

GFP
  • 260
  • 3
  • 10

1 Answers1

4
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.

Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • oooh... then insets() was just replaced by getInsets() ? o.O really strange.. but thank you :) – GFP Jul 23 '13 at 17:11
  • Yes but i need the null layout in this case. – GFP Jul 24 '13 at 14:32
  • @GFP no, you don't "need" a null layout - that's true to at least third approximation. What you doing is **exactly** the responsibility of a LayoutManager. Review your layout requirements and search a manager that suits your needs. – kleopatra Jul 24 '13 at 14:37
  • Okay okay ill end this discussion: I WANT to use a null layout here. I have a frame that has the sizeo ff 400x300, and its undecorated. No one can change the size or move it. And no one has a smaller screen than this. – GFP Jul 24 '13 at 14:49
  • @GFP still there are many things that can change (font f.i.) - you make your own life miserable, and deserve it – kleopatra Jul 25 '13 at 12:13
  • and still its my thing to use the null layout or not. – GFP Jul 25 '13 at 14:35