I tried using the JPanel but it's going to make padding/margin around itself, and i don't want that.
The default layout manager for a panel is the FlowLayout
. If you don't like the padding then get rid of the padding. Read the FlowLayout API for more information on how to do this.
Or you could use a BoxLayout
in your panel. It does not add padding. Read the Swing tutorial on Layout Managers for more information.
actually i like don't using jpanel, because when i resize my jpanel if there is not space enough for the title it becomes like My Tit..,
Every layout manager has to make a decision what to do when there is not enough space. Read the tutorial and try the different layout managers to determine the one the best suits your needs.