我想要做的就是让JTextPane在JPanel中占用尽可能多的空间.
对于我正在使用的UpdateInfoPanel:
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("
News
");JScrollPane scrollPane = new JScrollPane(textPane);
add(scrollPane);
setBackground(Color.DARK_GRAY);
textPane.setBorder(BorderFactory.createLineBorder(Color.BLACK));
}
}
对于我的框架,我只需创建一个这样的实例并将其放在BorderLayout.CENTER中.
目前这是它的外观.白色边框是滚动窗格,黑色是文本窗格.我想要做的是让边框位于面板的边缘.
![] [1]