Add Object to JPanel after button click
I have created a JScrollPane with a JPanel inside it and I want to add JPanel/JLabel/Other objects after pressing the button. For example after three button presses I want to get something like this: I tried myJPane.add(testLabel) with testlabel.setBounds() but no result, I don't want to use GridLayout because of the unchangeable sizes. I would like it if the added objects had different sizes - adjusted to the text content. What should I use for it and how? Thanks in advance. Best regards, Tom. Here is a JPanel inside a JScrollPane that adds JLabel s to it when pressing the button: public