I want to add multiple new JTextArea in JTextPane at runtime on button click. For that i have set Box layout for my JTextPane and i add new component in that using mytextpane.add() method.
but it is getting resized and repositioned depending on layout and does not retain the original size of it which i had assigned. Also as i add more component to it, the inserted components are getting shrinked but i want a scrollbar to show up when i add more components to my JTextPane. Please help me with this problem.
I want to add multiple new JTextArea in JTextPane at runtime on button click.
Share
Generally you add components to a JPanel, so I’m not sure why you are attempting to add them to a JTextPane. The basic code is:
However, if you really are trying to add them to a JTextPane then you should be using the insertComponent() method of JTextPane.
If you need more help post your SSCCE showing the problem.