I have JtabbedPane where every tab has a JtextPane wrapped inside a JScrollPane. The Vertical scroll bar is showing up when necessary, but the horizontal isn't, and instead of making a horizontal bar it cuts the text and continues it in next line, which is not a point. I have tried to resize the tab size and declaring the size of the scrollpane larger than tab's, but the result the same.
tabs = new TabbedPane();
tabs.setBounds(0, 0, windowWidth - 70, windowHight - 105);
for (Responses orgData: GUI.getOriginalRequest().getArrayOfResponses())
{
sc = StyleContext.getDefaultStyleContext();
style = sc.addStyle("ConstantWidth", null);
str = formatter.format((formatter.unformat(orgData.getXMLData())));
ksd = new KeywordStyledDocument(style, sc, s);
ksd.insertString(0, str, style);
ksd.refreshDocument();
pane = new JTextPane(ksd);
pane.setFont(new Font("Courier New", Font.PLAIN, 12));
panel = new JScrollPane(pane);
panel.getHorizontalScrollBar().addAdjustmentListener(null);
panel.setPreferredSize(new Dimension(windowWidth - 170, windowHight - 135));
orgData.setXMLData(formatter.unformat(str));
listener.addKeyAdapter(pane);
tabs.addTab(orgData.getSystemName() + " (Original Request)", panel);
}
What am I missing here?
Thank you.
Update:
After implementing the LineWrape by extending the JTextPane and adding pane.setLineWrap(false) that was sugested by Thanasis, the problem was resolved and the textPane which had a text that exceeded the bounds of the field, was wrapped and had a horizontal scroll bar, but textPane which text was less than the bounds of textPane was wrapped to the last character, and thus, the field became less than a space that is allocated to it, and it looks like panel split to 2 parts, textPane and panel.
How do I resolve this? Please suggest.