OmegaT の背景に画像を表示します。
OmegaT 3.1 対応 (#50229)
| @@ -33,9 +33,9 @@ | ||
| 33 | 33 | import javax.swing.JEditorPane; |
| 34 | 34 | import javax.swing.JFrame; |
| 35 | 35 | import javax.swing.JMenuBar; |
| 36 | +import javax.swing.JPanel; | |
| 36 | 37 | import javax.swing.JScrollPane; |
| 37 | 38 | import javax.swing.JTextPane; |
| 38 | -//import javax.swing.plaf.basic.BasicMenuBarUI; | |
| 39 | 39 | import org.omegat.core.Core; |
| 40 | 40 | import org.omegat.util.gui.UIThreadsUtil; |
| 41 | 41 |
| @@ -252,16 +252,10 @@ | ||
| 252 | 252 | // <body ... bgcolor="white" ...> |
| 253 | 253 | // そのため、コンポーネント自体を透過にしても、HTML Body 背景色の |
| 254 | 254 | // 白指定が効いて透過にならない。そこで、背景色指定を削除する。 |
| 255 | - for (DockableState d: desktop.getDockables()) { | |
| 256 | - Dockable dockable = d.getDockable(); | |
| 257 | - String key = dockable.getDockKey().getKey(); | |
| 258 | - if (key.equalsIgnoreCase("EDITOR")) { // found InstantStartGuide | |
| 259 | - JScrollPane sp = (JScrollPane) dockable.getComponent(); | |
| 260 | - JTextPane tp = (JTextPane) sp.getViewport().getView(); | |
| 261 | - tp.setText(tp.getText().replace(" bgcolor=\"white\"", "")); | |
| 262 | - tp.setCaretPosition(0); | |
| 263 | - return; | |
| 264 | - } | |
| 255 | + JEditorPane ep = getJEditorPaneFromEditor(desktop); | |
| 256 | + if (ep != null) { | |
| 257 | + ep.setText(ep.getText().replace(" bgcolor=\"white\"", "")); | |
| 258 | + ep.setCaretPosition(0); | |
| 265 | 259 | } |
| 266 | 260 | } |
| 267 | 261 |
| @@ -278,7 +272,20 @@ | ||
| 278 | 272 | for (DockableState d: desktop.getDockables()) { |
| 279 | 273 | Dockable dockable = d.getDockable(); |
| 280 | 274 | if (dockable.getDockKey().getKey().equalsIgnoreCase("EDITOR")) { |
| 281 | - JScrollPane sp = (JScrollPane) dockable.getComponent(); | |
| 275 | + JScrollPane sp; | |
| 276 | + | |
| 277 | + // OmegaT 3.1.0 or later | |
| 278 | + if (dockable.getComponent() instanceof JPanel) { | |
| 279 | + // dockable.getComponent() => org.omegat.gui.main.DockablePanel | |
| 280 | + // extends JPanel implements Dockable | |
| 281 | + JPanel jp = (JPanel) dockable.getComponent(); | |
| 282 | + sp = (JScrollPane) jp.getComponent(0); | |
| 283 | + | |
| 284 | + // less than OmegaT 3.1.0 | |
| 285 | + } else { | |
| 286 | + sp = (JScrollPane) dockable.getComponent(); | |
| 287 | + } | |
| 288 | + | |
| 282 | 289 | return (JEditorPane) sp.getViewport().getView(); |
| 283 | 290 | } |
| 284 | 291 | } |