Почему?
Код: Выделить всё
Hello![/b][b]
Но меня волнует наше приложение Swing. Почему комментарии не учитываются?
Код: Выделить всё
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
public class EditorPaneDemo {
private static JEditorPane editorPane;
public static void main(String[] args) {
Container mainPanel = createMainPanel();
JFrame frame = new JFrame("Editor Pane demo");
frame.setContentPane(mainPanel);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
private static JPanel createMainPanel() {
JPanel panel = new JPanel();
panel.add(createScrollPane());
return panel;
}
private static JScrollPane createScrollPane() {
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(createEditorPane());
scrollPane.setPreferredSize(new Dimension(200, 150));
return scrollPane;
}
private static JEditorPane createEditorPane() {
editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText(getEditorPaneText());
return editorPane;
}
private static String getEditorPaneText() {
return "\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
" Hello[/b]\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" \n" +
"";
}
}
Я действительно не думаю, что нужно добавлять какие-либо подробности
Подробнее здесь: https://stackoverflow.com/questions/790 ... ts-applied