<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- $Id: head.tmpl,v 1.5 2002/12/15 01:30:47 carstenklapp Exp $ -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="index,follow" />
<meta name="keywords" content="Java Beans, PhpWiki" />
<meta name="description" content="Type in a URL or double-click a URL from the list. Use the ~Go menu to go back to a previous link or step to the next link you already visited." />
<meta name="language" content="" />
<meta name="document-type" content="Public" />
<meta name="document-rating" content="General" />
<meta name="generator" content="phpWiki" />
<meta name="PHPWIKI_VERSION" content="1.3.4" />

<link rel="shortcut icon" href="/wiki/themes/default/images/favicon.ico" />
<link rel="home" title="HomePage" href="HomePage" />
<link rel="help" title="HowToUseWiki" href="HowToUseWiki" />
<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1" />
<link rel="author" title="The PhpWiki Programming Team" href="http://phpwiki.sourceforge.net/phpwiki/ThePhpWikiProgrammingTeam" />
<link rel="search" title="FindPage" href="FindPage" />
<link rel="alternate" title="View Source: JavaBeans" href="JavaBeans?action=viewsource&amp;version=13" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="RecentChanges?format=rss" />

<link rel="bookmark" title="SandBox" href="SandBox" />
<link rel="bookmark" title="WikiWikiWeb" href="WikiWikiWeb" />



<link rel="stylesheet" title="MacOSX" type="text/css" charset="iso-8859-1" href="/wiki/themes/MacOSX/MacOSX.css" /><link rel="alternate stylesheet" title="Printer" type="text/css" charset="iso-8859-1" href="/wiki/themes/default/phpwiki-printer.css" media="print, screen" /><link rel="alternate stylesheet" title="Modern" type="text/css" charset="iso-8859-1" href="/wiki/themes/default/phpwiki-modern.css" /><style type="text/css">
<!--
body {background-image: url(/wiki/themes/MacOSX/images/bgpaper8.png);}
-->
</style>
<title>PhpWiki - Java Beans</title>
</head>
<!-- End head -->
<!-- Begin body -->
<!-- $Id: body.tmpl,v 1.30 2002/09/02 14:36:58 rurban Exp $ -->
<body>
<!-- Begin top -->
<!-- $Id: top.tmpl,v 1.20 2002/12/15 01:30:47 carstenklapp Exp $ -->

<!-- End top -->
<!-- Begin browse -->
<!-- $Id: browse.tmpl,v 1.22 2002/02/19 23:00:26 carstenklapp Exp $ -->


<div class="wikitext"><p><b>Quick Introduction</b></p>
<p>Run the example program that demonstrates the capabilities of the Java Beans that are already included in the htmparser.jar (it's assumed that the htmlparser.jar file from an integration build 1.3 later than April 12, 2003 is in your current directory):</p>
<pre>
java -classpath htmlparser.jar org.htmlparser.beans.BeanyBaby</pre>
<p>What you should see is a split window showing a URL extraction with a list of links on the left and the text on the right.<br /></p>
<p><img src="http://htmlparser.sourceforge.net/images/BeanyBaby.jpg" alt="http://htmlparser.sourceforge.net/images/BeanyBaby.jpg" class="inlineimage" /><br /></p>
<p>The splitter on the left contains a GUI oriented <tt>HTMLLinkBean</tt> (which uses an underlying API <tt>LinkBean</tt>) and the splitter on the right contains a GUI oriented  <tt>HTMLStringBean</tt> (which uses an underlying API <tt>StringBean</tt>).<br /></p>
<p>Type in a URL or double-click a URL from the list. Use the Go menu to go back to a previous link or step to the next link you already visited.</p>
<p>The options menu provides access to the binary properties:<br /></p>
<p><img src="http://htmlparser.sourceforge.net/images/BeanyBabyOptions.jpg" alt="http://htmlparser.sourceforge.net/images/BeanyBabyOptions.jpg" class="inlineimage" /><br /></p>
<ul>
<li>Links - turn on and off the extraction of hyperlinks with the text</li>
<li>Collapse - turn on and off collapsing whitespace</li>
<li>Non-Breaking Spaces - turn on and off transforming non-break spaces into regular spaces</li>
</ul>
<p><b>Simple Usage</b></p>
<p>The simplest operation (this shows StringBean use, but LinkBean use is similar) is just to create a new one, set the URL and then get the text:<br /></p>
<pre>
#import org.htmlparser.beans.StringBean;

public class TryBeans
{
    public static void main (String[] args)
    {
        StringBean sb = new StringBean ();
        sb.setURL ("<a href="http://cbc.ca" class="namedurl"><span style="white-space: nowrap"><img src="../themes/MacOSX/images/http.png" alt="http" class="linkicon" border="0" />http://cbc.ca</span></a>");
        System.out.println (sb.getStrings ());
    }
}</pre>
<p>Save this in a file called TryBeans.java and then run the following commands:</p>
<pre>
javac -classpath htmlparser.jar TryBeans.java
java -classpath htmlparser.jar:. TryBeans</pre>
<p>or for Windows:</p>
<pre>
java -classpath htmlparser.jar;. TryBeans</pre>
<p><b>Simple GUI Usage</b></p>
<p>The following instructions are for the <a href="http://www.netbeans.org" class="namedurl"><span style="white-space: nowrap"><img src="../themes/MacOSX/images/http.png" alt="http" class="linkicon" border="0" />NetBeans</span></a> IDE but other environments will have a similar operation.</p>
<p>You can mount the htmlparser.jar file:<br /></p>
<p><img src="http://htmlparser.sourceforge.net/images/Mount.jpg" alt="http://htmlparser.sourceforge.net/images/Mount.jpg" class="inlineimage" /><br /></p>
<p>and use the bean classes directly or if you want to use them in the Form designer you'll need to install them. Use the Install New Javabean menu item in the Tools menu:<br /></p>
<p><img src="http://htmlparser.sourceforge.net/images/InstallBean.jpg" alt="http://htmlparser.sourceforge.net/images/InstallBean.jpg" class="inlineimage" /><br /></p>
<p>There are a number of beans in the jar, as indicated above the GUI beans are the HTMLStringBean and HTMLLinkBean. You can install them all, but it might clutter up your palette a bit, so I would recomend only install the ones you need for the project at hand. You'll also need to specify the palette that the beans will be added to:</p>
<p><img src="http://htmlparser.sourceforge.net/images/ChooseBean.jpg" alt="http://htmlparser.sourceforge.net/images/ChooseBean.jpg" class="inlineimage" />
<img src="http://htmlparser.sourceforge.net/images/ChoosePalette.jpg" alt="http://htmlparser.sourceforge.net/images/ChoosePalette.jpg" class="inlineimage" /><br /></p>
<p>Once the bean is installed it will show up on the tool palette and you can click it and drop it onto a JFrame or JPanel or whatever:<br /></p>
<p><img src="http://htmlparser.sourceforge.net/images/AddingBean.jpg" alt="http://htmlparser.sourceforge.net/images/AddingBean.jpg" class="inlineimage" /><br /></p>
<p>Once it's in your designer you can set the properties and have it display the text even while designing (assuming you're online):<br /></p>
<p><img src="http://htmlparser.sourceforge.net/images/SettingProperties.jpg" alt="http://htmlparser.sourceforge.net/images/SettingProperties.jpg" class="inlineimage" /><br /></p>
<p>Of course you can subclass the provided beans or write your own.</p>
</div>


<!-- End browse -->
<!-- Begin bottom -->
<!-- $Id: bottom.tmpl,v 1.3 2002/09/15 20:21:16 rurban Exp $ -->
<!-- Add your Disclaimer here -->
<!-- Begin debug -->
<!-- $Id: debug.tmpl,v 1.9 2002/09/17 02:10:33 dairiki Exp $ -->
<table width="%100" border="0" cellpadding="0" cellspacing="0">
<tr><td>

</td><td>
<span class="debug">Page Execution took 0.351 seconds</span>
</td></tr></table>
<!-- This keeps the valid XHTML! icons from "hanging off the bottom of the scree" -->
<br style="clear: both;" />
<!-- End debug -->
<!-- End bottom -->
</body>
<!-- End body -->
<!-- phpwiki source:
$Id: prepend.php,v 1.13 2002/09/18 19:23:25 dairiki Exp $
$Id: ErrorManager.php,v 1.16 2002/09/14 22:23:36 dairiki Exp $
$Id: HtmlElement.php,v 1.27 2002/10/31 03:28:30 carstenklapp Exp $
$Id: XmlElement.php,v 1.17 2002/08/17 15:52:51 rurban Exp $
$Id: WikiCallback.php,v 1.2 2001/11/21 20:01:52 dairiki Exp $
$Id: index.php,v 1.99 2002/12/31 01:13:14 wainstead Exp $
$Id: main.php,v 1.90 2002/11/19 07:07:37 carstenklapp Exp $
$Id: config.php,v 1.68 2002/11/14 22:28:03 carstenklapp Exp $
$Id: FileFinder.php,v 1.11 2002/09/18 18:34:13 dairiki Exp $
$Id: Request.php,v 1.24 2002/12/14 16:21:46 dairiki Exp $
$Id: WikiUser.php,v 1.29 2002/11/19 07:07:38 carstenklapp Exp $
$Id: WikiDB.php,v 1.17 2002/09/15 03:56:22 dairiki Exp $
$Id: SQL.php,v 1.2 2001/09/19 03:24:36 wainstead Exp $
$Id: mysql.php,v 1.3 2001/12/08 16:02:35 dairiki Exp $
$Id: PearDB.php,v 1.28 2002/09/12 11:45:33 rurban Exp $
$Id: backend.php,v 1.3 2002/01/10 23:32:04 carstenklapp Exp $
$Id: DB.php,v 1.2 2002/09/12 11:45:33 rurban Exp $
From Pear CVS: Id: DB.php,v 1.13 2002/07/02 15:19:49 cox Exp
$Id: PEAR.php,v 1.1 2002/01/28 04:01:56 dairiki Exp $
From Pear CVS: Id: PEAR.php,v 1.29 2001/12/15 15:01:35 mj Exp
$Id: mysql.php,v 1.2 2002/09/12 11:45:33 rurban Exp $
From Pear CVS: Id: mysql.php,v 1.5 2002/06/19 00:41:06 cox Exp
$Id: common.php,v 1.2 2002/09/12 11:45:33 rurban Exp $
From Pear CVS: Id: common.php,v 1.8 2002/06/12 15:03:16 fab Exp
$Id: themeinfo.php,v 1.46 2002/03/08 20:31:14 carstenklapp Exp $
$Id: Theme.php,v 1.58 2002/10/12 08:55:03 carstenklapp Exp $
$Id: display.php,v 1.38 2002/09/15 20:17:58 rurban Exp $
$Id: Template.php,v 1.46 2002/09/15 15:05:47 rurban Exp $
$Id: WikiPlugin.php,v 1.27 2002/11/04 03:15:59 carstenklapp Exp $
$Id: BlockParser.php,v 1.29 2002/11/25 22:25:49 dairiki Exp $
$Id: InlineParser.php,v 1.19 2002/11/25 22:51:37 dairiki Exp $
$Id: interwiki.php,v 1.23 2002/10/06 16:45:10 dairiki Exp $
$Id: PageType.php,v 1.13 2002/09/04 20:39:47 dairiki Exp $
-->
</html>
