私がやろうとしているのは、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("<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));
}
}
そして私のフレームでは、これのインスタンスを作成してBorderLayout.CENTERに配置するだけです。現在、これはどのように見えるかです。白の境界線はスクロールペイン、黒はテキストペインです。私がやりたいのは、境界線をパネルの端に配置することです。 ![] [1]