CalHTMLPane v2.0 Guide Programming Answers

Programming Answers


1. I don't want hyperlinks to be marked as visited and I can't see a method in CalHTMLPreferences to turn this feature off.

The easiest way to turn this off is simply to set the default color of visited links to that of unvisited links. You can do this through a method in CalHTMLPreferences. So your code will look something like this:

CalHTMLPreferences pref = new CalHTMLPreferences();
pref.setDefaultColor(CalCons.A_VLINK, pref.getDefaultColor(CalCons.A_LINK));
CalHTMLPane pane = new CalHTMLPane(pref, null, null);

2. CalPane uses THREEDEE style form components as default. I'd like to have LOOKANDFEEL components as default. How do I do this?

You can make all components render in the current Look And Feel by setting a property in CalHTMLPreferences:

CalHTMLPreferences pref = new CalHTMLPreferences();
pref.setFormRenderingStyle(CalCons.USE_LOOK_AND_FEEL);
CalHTMLPane pane = new CalHTMLPane(pref, null, null);

3. Is it possible to do something like hyperlink-hover which you see in some help systems?

Yes, there's a method in CalHTMLPreferences that enables you to do this:

CalHTMLPreferences pref = new CalHTMLPreferences();
pref.setShowHyperlinkOnMouseFocus(true);
CalHTMLPane pane = new CalHTMLPane(pref, null, null);

4. I'm including some form components in a table. Each component is in its own table cell and the cell has got a border. I want the component to fill the cell, but there's always a gap above it. How can I get rid of this?

Change the alignment of the form component to something other than its default, which is a few pixels below the text baseline. For example:

<TD><INPUT type=text align=top></TD>


5. I've got a document which has many form controls, each of which has its own id. I get the the CalPane to load this document and then I call the getIDComponents() method to access the components. However the Hashtable returned from this call is empty. Here's my code:

pane.showHTMLDocument(url);
pane.getIDComponents(null);
The CalPane will load the document asynchronously, so the showHTMLDocument() method will return immediately, and you are consequently making the call to get the components before they have been created. You need to ensure that the document has loaded before you try and get the components. You can either do this by using CalHTMLObserver callbacks to monitor document loading, or you can force the document to load synchronously with the setLoadSynchronously() method like this:
pane.setLoadSynchronously(true);
pane.showHTMLDocument(url);
pane.setLoadSynchronously(false);
pane.getIDComponents(null);
Guide Index  |  JavaDoc  |  Previous  |  Next