0

Just wondering if there is any way to do absolute positioning for a JPanel without using a null layout. My end goal is to have the JComponent instances move relative to the size of the frame (and thus the panel) whilst still being able to put them exactly where I want them with absolute positioning.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Darcy Sutton
  • 111
  • 6
  • 1
    Seems an opportunity to make your own ScalingAbsoluteLayout.. It would be senseless for people to code an AbsoluteLayout or NullLayout, but search. GUI builders might use such a layout manager. – Joop Eggen Oct 14 '21 at 09:16
  • 1
    Maybe [GroupLayout](https://docs.oracle.com/javase/tutorial/uiswing/layout/group.html) or [SpringLayout](https://docs.oracle.com/javase/tutorial/uiswing/layout/spring.html) is appropriate? – Abra Oct 14 '21 at 09:18
  • Probably not quite what you're looking for, but as a reference [this](https://stackoverflow.com/questions/11819669/absolute-positioning-graphic-jpanel-inside-jframe-blocked-by-blank-sections/11822601#11822601) makes use of percentage based positioning layout (not really meant for components, but it gives you some idea of the complexity of the task) – MadProgrammer Oct 14 '21 at 10:20
  • 1
    `GridBagLayout` also has constraints that allow you to specify how components grow/shrink as the panel size changes. So does the `GridLayout`. Without a specific requirement we can't provide a specific suggestion. – camickr Oct 14 '21 at 14:13
  • *"Thank you."* Tip: add @camickr (or whoever, the `@` is important) to *notify* a person of a new comment. – Andrew Thompson Oct 15 '21 at 05:50

0 Answers0