スクロールバー付きの JEditorPane を 2 時間作成しようとしましたが、あきらめようとしています。
これは私のコードの一部です:
JEditorPane editorPane = new JEditorPane();
URL helpURL = GUIMain.class
.getResource("/resources/einleitungstext1.html");
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
try {
editorPane.setPage(helpURL);
} catch (IOException e) {
System.err.println("Attempted to read a bad URL: " + helpURL);
}
editorPane.setEditable(false);
JScrollPane editorScrollPane = new JScrollPane(editorPane);
editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setMinimumSize(new Dimension(100, 100));
editorScrollPane.setPreferredSize(new Dimension(main.screenWidth-200, main.screenHeight-200));
c.gridx = 0;
c.gridy = 0;
this.add(editorScrollPane, c);
this.setVisible(true);
this.add(editorScrollPane,c) を実行するとフレームが空になりますが、this.add(editorPane, c) を実行するとパネルが表示されます。this.add(new JLabel("test"),c) でもフレームは空です。
私のエラーはどこですか?
ありがとうございました
PS かなり大きいので、コード全体を投稿することはできません。