I want to have a frame (or similar) which contains 5 buttons, each located at specific coordinates (not in a rectangular order or a strict grid) and some lines which connect some of buttons.
My initial approach would be:
- Open a frame
- Place the buttons at the desired coordinates
- Draw the lines between the buttons using the coordinates of the buttons
The problem is, I can either place buttons or draw lines. I am searching the net since 2 evenings and did only find solutions which can do either or. And I cannot figure out why it is not working.
This one here explains very well how to draw multiple lines:
But I do not get any visible buttons in the same field (component) as the lines. They are always either not visible or in another area no matter whichever I try.
I would be very grateful if somebody could give me a real example with a short explanation. I am very new to Java and teaching “myself”, …
Thanks, Lubenja
EDIT after MadProgrammer's comment and eatinasandwich'S answer:
I agree, that these layout managers may do great jobs. I read about a few of them and think they help if you are using a fixed and rectangual layout.
However, I want to have something like this (see below). Whereby I want to program a overall program, which allows me to change the positions easily and/or to add new buttons and the corresponding lines. Therefore I was more in favour of coordinates than a layout manager. (Layout here: http://4.bp.blogspot.com/-hSkZGDick6o/VIfkt-m6ZvI/AAAAAAAAAMw/MA2JunqHu0Q/s1600/Layout.png, can't upload images yet) .
okay! layout managers can do the trick!