I have the following problem:
I have a JTextPane
on the left filled with content and this JTextPane
is placed into a JScrollPane
. This ScrollPane
is added to the BorderLayout.CENTER
of a JPanel
and this resulting JPanel
is added to BorderLayout.CENTER
of the underlaying JFrame contentPane()
.
Now I want to spread this JTextPane
all over the JFrame/JPanel
.
How can I achieve this?
Here is the code:
public class FinishPanelBuilder extends JPanel
{
/**
* Serial version UID.
*/
private static final long serialVersionUID = 4373044358025740572L;
private Model model;
/**
* Constructor to call if you want to build up a new finish panel.
*
* @param model
*/
public FinishPanelBuilder()
{
buildFinishPanel();
}
/**
* Builds up the panel.
*/
public void buildFinishPanel()
{
setLayout(new BorderLayout());
JTextWrapPane textPaneResult = new JTextWrapPane();
//This is my own class of JTextPane to wrap text
StyledDocument document = textPaneResult.getStyledDocument();
textPaneResult.setEditable(false);
textPaneResult.setBackground(Color.white);
textPaneResult.setFont(panelLabel.getFont());
textPaneResult.setAutoscrolls(true);
textPaneResult.setLineWrap(false);
JScrollPane scrollPaneTestResult = new JScrollPane(textPaneResult);
scrollPaneTestResult.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
panelLabel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
setBorder(BorderFactory.createEtchedBorder());
add(panelLabel, BorderLayout.PAGE_START);
add(scrollPaneTestResult, BorderLayout.CENTER);
}
}
This complete code is called by a
JFrame frame = new JFrame();
frame.add(new FinishPanelBuilder();