WebRenderer has some convenience methods to allow the construction
of a Swing status bar. Using the JProgressBar
and JLabels it is easy to create a browser
status bar based upon the WebRenderer Browser
and Network events.
Using
Events to bring your Status Bar to life WebRenderer
has some useful Network Events (com.webrenderer.events) to bring
status bars and load progress bars to life.
browser.addNetworkListener(new
NetworkAdapter() { public
void onProgressChange(NetworkEvent e) {
//For
getting text of the load progress System.out.println("Status
Text: "+e.getStatusText());
//Number
of bytes downloaded System.out.println("Bytes
downloaded: "+e.getCurrentProgress()); } });
Within
the NetworkEvent class progress bar sizing
and increment can be calculated by the following:
public
void onProgressChange(NetworkEvent e) {
//Total number of
bytes to download for the page int
maxNumberOfBytes = e.getMaximumProgress();
//Status bar progress
maximum size int maxsize
= e.getMaximum(); }
Within the
BrowserEvent class events such as onBeforeNavigate
and onLinkChange are particularly useful
for status bars.
browser.addBrowserListener(new
BrowserAdapter() { public
void onBeforeNavigate(BrowserEvent e) { System.out.println("Navigating
to: " + e.getURL()); } public
void onLinkChange(BrowserEvent e) { System.out.println("Link:
" + e.getLink()): } });