ho visto che dentro JEditorPane è possibile visualizzare pagine web.
allora ho creato un piccolo testo con un link.
al click su link si apre una pagina, mala visualizzazione è unpò sballata.
mi chiedevo se è normale o se mi manca qualcosa:
codice:editorCopyright = new javax.swing.JEditorPane(); editorCopyright.setContentType("text/html"); editorCopyright.setEditable(false); editorCopyright.setText("<html>\n <head>\n\n </head>\n <body>\n <div>\n <span style=\"background-color: #ffffff; color: #000000;\">Tutto il materiale all’interno di questo portale, è pubblicato con licenza <a href=\"http://creativecommons.org/licenses/by/2.5/it/\" target=\"_blank\">Creative Commons</a><a href=\"http://creativecommons.org/licenses/by/2.5/it/\" target=\"_blank\">attribuzione 2.5 Italia.</a></span></p>\n <span style=\"background-color: #ffffff; color: #000000;\">Siete liberi di riprodurre, distribuire, comunicare al pubblico, esporre in pubblico, rappresentare, eseguire e recitare quest’opera, e di modificare quest’opera, purchè ne attribuiate la paternità a questo portale ed il relativo autore, con un link alla fonte originale.</span></p>\n</div>\n </body>\n</html>\n"); editorCopyright.addHyperlinkListener(new javax.swing.event.HyperlinkListener() { public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) { editorCopyrightHyperlinkUpdate(evt); } }); ........ private void editorCopyrightHyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) { if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { editorCopyright.setPage(evt.getURL()); } catch (IOException ex) { JOptionPane.showMessageDialog(rootPane, ex.getMessage()); } } }

Rispondi quotando