FileDocCategorySizeDatePackage
HelperDiag.javaAPI DocJMF 2.1.1e3154Mon May 12 12:21:00 BST 2003com.sun.media.customizer

HelperDiag

public class HelperDiag extends JDialog
This dialog class provides the help information:
version
2.0

Fields Summary
JEditorPane
helpPane
int
anch
String[]
helpcontent
int
FILELEN
Constructors Summary
public HelperDiag(Customizer parent, int anch)


         
	super(parent, I18N.getResource("HelperDiag.TITLE"), false);
	this.anch = anch;

	try {
	    loadHTML();
	    helpPane = new JEditorPane("text/html",helpcontent[anch]);
	    helpPane.setBackground(Color.lightGray);
	    helpPane.setEditable(false);
	    // setResizable(true);
	    this.getContentPane().setLayout(new BorderLayout());
	    this.getContentPane().add("Center", new JScrollPane(helpPane));
	} catch (Exception ex) {
	    System.out.println(I18N.getResource("HelperDiag.ERROR"));
	    ex.printStackTrace();
	}

	this.addWindowListener(new CloseAdapter(parent, this));
    
Methods Summary
private java.io.InputStreamgetHelpFileStream()

	String helpfile = "CustomizerHelp.html";
	String retstr = helpfile;
	String classpath = System.getProperty("java.class.path");
	String pathsep = System.getProperty("path.separator");
	StringTokenizer st = new StringTokenizer(classpath, pathsep);
	while (st.hasMoreTokens()) {
	    String path = st.nextToken();
	    if (path.endsWith(".jar")) {
		ZipFile zipfile = new ZipFile(path);
		ZipEntry entry = zipfile.getEntry(helpfile);
		if ( entry != null ) {
		    FILELEN = (int)entry.getSize();
		    return zipfile.getInputStream(entry);
		}
	    }
	}
	return null;
    
private voidloadHTML()

	InputStream fin = getHelpFileStream();
	if ( fin == null){
	    // System.out.println("Can't find CustomizerHelp.html");
	    // return;
	    // System.exit(0);
	    throw new IOException(I18N.getResource("HelperDiag.ERROR"));
	}
	BufferedReader br = new BufferedReader(new InputStreamReader((fin)));
	char[] rawhtml = new char[FILELEN];
	int[] idx = new int[6];

	StringBuffer[] sb = new StringBuffer[6];
	for ( int i = 0; i < 6; i++ )
	    sb[i] = new StringBuffer();

	int len = br.read(rawhtml, 0, FILELEN);
	br.close();
	int j = 0;

	for ( int i = 0; i < len-1; i++) {
	    if ( rawhtml[i] == '<" && rawhtml[i+1] == 'a")
		idx[j++] = i;
	}

	for ( int i = 0; i < 5; i++ ) {
	    sb[i].append(rawhtml, idx[i], idx[i+1]-idx[i]);
	    helpcontent[i] = sb[i].toString();
	}
	sb[5].append(rawhtml, idx[5], len - idx[5]);
	helpcontent[5] = sb[5].toString();
    
public voidsetHelpPage(int idx)

	helpPane.setText(helpcontent[idx]);