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.
+1
A:
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:
panel.add( someComponent );
panel.revalidate();
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.
camickr
2010-02-19 06:06:36
please help me camickr
Nilesh
2010-02-19 08:42:06
A:
I doubt whether the JTextPane is the component you should be using for this purpose. JTextPane is suited when you want add a multline text editing interface to your UI (say embedding a markup editor). May be JScrollPane would better suit your needs.
sateesh
2010-02-19 06:19:42