I have put some JPanels into another JPanel which its\' layout is Box Layout and Y-Axis. After I have put all the panels I need to get the Y position of each added JPanel in
Please tell me how to get the Y position of each Jpanel from the JPanel container JPanel.
BoxLayout
accepting XxxSize
(Preferred
in this case) that returns its child,
JPanel
returns (0, 0) this is correct value
this or simlair result you can get from all LayoutManager
, for example built_in FlowLayout
for JPanel
(accepting only the PreferredSiz
e), returns the same coordinates (0, 0)
excepting BorderLayout
then is there generated 10pixels
(for W, E, N, S areas), and valid only in the case that CENTER area
is used for some JComponent
JPanel
is Container
and by empty JPanel
by defualt returns zero size on the screen,
JPanel
can to returns proper coordinates if is there any JComponent
or you override XxxSize
in the JPanel
constructor