Disable resizing of JTextPane
Hi
I joined my JPanel into a JScrollPane after I added up the JtextPane, there is no problem but when I enter data into the JTextPane of the JScrollPane JPanel grow automatically. I want to know how to disable resizing of JTextPanel when I try to re-size it. Thank you for your help.
Re: Disable resizing of JTextPane
Hello,
Could you explain it in an understandable and comprehensible way. I am having probelm in understanding your exact problem, I'll admit, but I did not understand much about the organization of your components, the layout used, what are you waiting to see the JScrollPane and so on. How you have arranged your components in your program. What have you changed in your code, so that you want to resize the JTextPane.
Re: Disable resizing of JTextPane
Hello,
I will not meter my code that exceeds 2000 lines but I will summarize, I'm fine detail and I would be very clear, here is my part of code
Code:
JFrame frm = new JFrame();
JPanel pan = new JPanel();
JScrollPane jsppan = new JScrollPane();
jsppan.setBounds(62, 72, 820, 500);
jsppan.setViewportView(pan);
pan.setAutoscrolls(false);
pan.setLayout(null);
JTextPane txt = new JTextPane();
txt.setBounds(30,30,100,100);
pan.add(txt);
jsppan.setBounds(100,100,600,600);
JPanel PaneauPrincipal = new JPanel();
My problem as I told you when I typed in the txt the JspPan re-sizes and I have no idea how it behaves like that.
Re: Disable resizing of JTextPane
Hello,
Stop using the NullLayout it will immediately be better for you. The NullLayout fits very well with the JScrollPane. Also in your case I do not understand the need to insert a JPanel JScrollPane between them and your JTextPane. You should rather put them directly in your JTextPane JScrollPane (but anyway since you're using NullLayout it will not work very well either). The NullLayout is a bad practice swing.
Re: Disable resizing of JTextPane
Hello,
The the above post mentioned that using the NullLayout is not a good practice, I think he is correct, even I am with him, some time before when I used NullLayout is did gave me some problems. Rather I suggest you to go for manager Layouts as well as FormLayout. The TableLayout, the MigLayout or use correctly layouts provided by Java (BorderLayout, BoxLayout, FlowLayout and the others.
Re: Disable resizing of JTextPane
Hello,
What you know is in my code that Jtextpane, I can resize and move it that's why I made a setLayout (null) and that is why I work with that, you think setBounds, the FormLayout, the TableLayout are a proper option to use here. But I feel these not work well with my program. Any other alternative will be highly recommended. By the way thanks for your help guys.