[java] HTML in JTextPane word zwart op een ander scherm

Pagina: 1
Acties:

  • Red devil
  • Registratie: December 1999
  • Nu online
Geachte tweakers,

Laat mbv JTextPane simpele HTML texten zien. Het geheel werkt perfect in een Eclipse RCP omgeving, echter als ik de view met de JTextPane lostrek en deze naar een andere monitor trek, wordt deze helemaal zwart. (voorbeeld linkje)

Dit is de code die ik gebruik.

Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
JTextPane detailedInfoTextPane = new JTextPane();

en later..

    private void setDetailedInfoTextPane(){

        detailedInfoTextPane.setBorder(BorderFactory.createTitledBorder("Detailed information"));
        detailedInfoTextPane.setBackground(new Color(236, 233, 216));
        // Set the textpane's font properties
        MutableAttributeSet attr = new SimpleAttributeSet();
        StyleConstants.setFontFamily(attr, "Arial");
        StyleConstants.setFontSize(attr, 14);
        StyleConstants.setBold(attr, false);
        detailedInfoTextPane.setCharacterAttributes(attr, false);
        detailedInfoTextPane.setContentType("text/html");
        detailedInfoTextPane.setEditable(false);
        detailedInfoTextPane.setEditorKit(new HTMLEditorKit());
        detailedInfoTextPane.setToolTipText("Detailed info");

        detailedInfoTextPane.addHyperlinkListener(new HyperlinkListener() {
//          PopupPanel  popUpMenu = null;   
            /** Used to save the previous tooltip. */
            private String tooltip;

            public void hyperlinkUpdate(HyperlinkEvent e) {

                if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
    
                    Element el = e.getSourceElement();
                    AttributeSet set  = el.getAttributes();
                    SimpleAttributeSet o = (SimpleAttributeSet)set.getAttribute(HTML.Tag.A);


                    for(Enumeration ee = o.getAttributeNames(); ee.hasMoreElements();){
                        Object ooo = ee.nextElement();
                        Object result = o.getAttribute(ooo);
                        if(ooo.toString().equals("title")){
                            tooltip = result.toString();
                        }

                    }
                    detailedInfoTextPane.setToolTipText(tooltip);
                }
            }
        });
    }