Please help me figure it out
The style section seems to be commented out but it does get applied
How come?
<html>
<head>
<style type="text/css">
<!--
body { font-family: verdana; font-size: 10pt; background-color: #FFFFDF; margin-top: 5; margin-right: 5; margin-bottom: 5; margin-left: 5 }
table { font-family: verdana; font-size: 10pt }
pre { font-family: verdana; font-size: 10pt }
th.tight { padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px }
td.tight { padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px }
div.cellwidener { margin-top: 2px; margin-right: 5px; margin-bottom: 2px; margin-left: 5px }
-->
</style>
</head>
<body scroll="no">
<table>
<tr>
<td rowspan="7" valign="top">
<div>
<b>Hello!</b>
</div>
</td>
</tr>
</table>
</body>
</html>
I don’t care about browsers. When it comes to browsers, anything goes, I guess
But I do care about our Swing application. Why aren’t comments respected?
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 "<html>n" +
" <head>n" +
" <style type="text/css">n" +
" <!--n" +
" body { font-family: verdana; font-size: 10pt; background-color: #FFFFDF; margin-top: 5; margin-right: 5; margin-bottom: 5; margin-left: 5 }n" +
" table { font-family: verdana; font-size: 10pt }n" +
" pre { font-family: verdana; font-size: 10pt }n" +
" th.tight { padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px }n" +
" td.tight { padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px }n" +
" div.cellwidener { margin-top: 2px; margin-right: 5px; margin-bottom: 2px; margin-left: 5px }n" +
" -->n" +
" </style>n" +
" n" +
" </head>n" +
" <body scroll="no">n" +
" <table>n" +
" <tr>n" +
" <td rowspan="7" valign="top">n" +
" <div>n" +
" <b>Hello</b>n" +
" </div>n" +
" </td>n" +
" </tr>n" +
" </table>n" +
" </body>n" +
"</html>";
}
}
I got Java 8, Windows 10
I really don’t think there are any more details to add
11