| 179 | // getContentHeight() to fail because it returns zero. Instead we make |
| 180 | // things 10x more complicated so that images will work. |
| 181 | void requestContentHeight(final int width, final URL url) { |
| 182 | new Thread(new Runnable() { |
| 183 | public void run() { |
| 184 | final JEditorPane dummy = new JEditorPane(); |
| 185 | dummy.addPropertyChangeListener("page", new PropertyChangeListener() { |
| 186 | @Override |
| 187 | public void propertyChange(PropertyChangeEvent evt) { |
| 188 | int high = dummy.getPreferredSize().height; |
| 189 | editorPane.setPreferredSize(new Dimension(width, high)); |
| 190 | pack(); |
| 191 | setLocationRelativeTo(null); |
| 192 | ready = true; |
| 193 | } |
| 194 | }); |
| 195 | try { |
| 196 | dummy.setPage(url); |
| 197 | } catch (IOException e) { |
| 198 | e.printStackTrace(); |
| 199 | } |
| 200 | dummy.setSize(width, Short.MAX_VALUE); |
| 201 | } |
| 202 | }).start(); |
| 203 | } |
| 204 | } |