You cannot do this because the default layout manager takes care of rendering items in the panel.
If you really want to set the item in position, you can choose panel = new JPanel(null);
But wait a bit! Do you really want to do this? I believe not. We (java programmers) usually use the service provided by layout managers to render elements on the screen. You have to spend an hour to learn and understand the concept, and then I promise you that you will use this technique and forget about manually rendering the elements on the screen as an insult to a very bad dream.
Alexr source share