How to create Jlabel inside JTextArea like on Facebook?

Is there a way to create a JTextArea or JTextField with some JLabels inside it, as in this screenshot from Facebook:

sample

What I'm trying to do is add some JButtons with names like "Apple", "Orange", ... When a user clicks on those JButton, say "Orange", Jlabel with the word "orange" is added to JTextArea or JTextField . If the user clicked [x] on Jlabel, the word will be removed from the field.

+7
source share
1 answer

I would have solved it differently: create a JPanel with the border you see. Add a JTextField without any borders to it and just paste the JLabel left (for example, using BorderLayout in combination with FlowLayout ). With a little customization of boundaries and distances, you should be able to create a very similar look without the need to create new components.

+6
source

All Articles