我正在做的事是讓JTextPane在JPanel中佔用儘可能多的空間。 對於我UpdateInfoPanel我使用:JTextPane JFrame中Janel中的JScrollPane中
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]
我喜歡暗灰色的外觀 – Adam
爲了更快地獲得更好的幫助,請發佈[SSCCE](http://sscce.org/)。你的問題是什麼? –
我的問題是如何使邊界動態伸展到兩邊? – Chris