Reputation: 3
i'm making a title bar, and i'm putting the title on the left and two buttons on the right. But if I use BorderLayout.EAST for both buttons, only the last one will be showed. Can I get both visible? I tried using the JPanel but it's going to make padding/margin around itself, and i don't want that. I tried removing it using createEmptyBorder(0, 0, 0, 0) but nothing changed..
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.., instead if i put the button in the JPanel it doesn't, it's like there's something above the text..
Upvotes: 0
Views: 217
Reputation: 324108
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.
Upvotes: 3