я пытался в течение 2 часов сделать JEditorPane с полосой прокрутки, и я собираюсь сдаться!
Это часть моего кода:
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) кадр пуст.
Где моя ошибка?
Спасибо
P.S. Я не могу опубликовать весь код, потому что он довольно большой.