How can I set a component (say button) at center of the panel? I used Flowlayout with layout constraint as center, but I am getting button at top-center position of the panel.
Flowlayout
This can be achieved using either GridBagLayout as mentioned by AVD1 or BoxLayout. See this answer for sample code.
GridBagLayout
BoxLayout
Personally I'd use GBL for this because fewer lines of code are required to get the component laid out & on-screen (centered in the parent container).
2.1m questions
2.1m answers
60 comments
57.0k users