This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using NetBeans to develop my swing application. I have one JTextPane which I have placed within a JScrollPane. My first issue was to disable the line wrap. To do this I extended the JTextPane and overrode the getScrollableTracksViewportWidth() to return false. The problem I have is that once i created a wrapper for the JTextPane, when I run the application the width of the TextPane is 0 and when I start typing in the in the textpane it expands. I would like the size of the textpane to be the size of the scrollpane. Please tell me what I am missing. If i change the textpane definition to JTextPane() then the size of the textPane is the size of the scrollPane, but then obviously the line wrapping is enabled. So here is what I have
The textPane is defined as
And this is the code generated for the initialization of the textPane
I hope I am clear enough. Any idea what I can do to make sure the textPane is the same size of the scrollPane?