What I am trying to do is make it so the JTextPane takes up as much space as possible in the JPanel.
For my UpdateInfoPanel I am using:
public class UpdateInfoPanel extends JPanel {
private static final long serialVersionUID = 257125249175323679L;
private JTextPane textPane;
public UpdateInfoPanel(){
textPane = new JTextPane();
textPane.setBackground(Color.DARK_GRAY);
textPane.setEditable(false);
textPane.setMargin(null);
textPane.setContentType("text/html");
textPane.setText("<html><body style=\"font: Arial; color: white; padding: 5px; padding-top: 0;\"><h1 style=\"padding-top: 0;\">News</h1></body></html>");
JScrollPane scrollPane = new JScrollPane(textPane);
add(scrollPane);
setBackground(Color.DARK_GRAY);
textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK));
}
}
And for my frame I simply create an instance of this and put it in BorderLayout.CENTER.
Currently this is how it looks. White border is the scroll pane, black is the textpane. What I want to do is have the borders be at the edge of the panel.
![][1]
Are you setting layout of your panel?
If you dont need the border of textpane do
textPane.setBorder(null);Dont extend the
JPanel. You can create is as you create theJTextPane.