/** * Filter for HTML labels in Netscape 4. * * @version 20030530 * @author Jörg P. M. Haeger */ class JLabel extends javax.swing.JLabel { private static int counter = 0; JLabel() { super(); } JLabel(String text) { this(); if (text.indexOf("") >= 0) { if (counter++ == 0) { System.out.print("Loading HTML viewer..."); System.out.flush(); try { setText(text); System.out.println(" done"); } catch (Throwable e) { System.out.println("<" + e + ">"); } } if (CDcreator.isNetscapeVM()) text = HTMLToText(text); } setText(text); } static String HTMLToText(String str) { char[] src = str.toCharArray(); char[] dest = new char[src.length]; int j = 0; for (int i = 0; i < src.length; i++) if (src[i] == '<') { if ((src[i + 1] == 'b' && src[i + 2] == 'r') || (src[i + 1] == '/' && src[i + 2] == 'h') || (src[i + 1] == '/' && src[i + 2] == 'p')) dest[j++] = '\n'; while (i < src.length && src[i] != '>') i++; } else if (src[i] == '\n') dest[j++] = ' '; else dest[j++] = src[i]; return new String(dest, 0, j); } }